| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 916331 | rainboy | Binary Subsequences (info1cup17_binary) | C11 | 643 ms | 396 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
#define INF 0x3f3f3f3f
int length(int a, int b) {
int l;
if (b == 0)
return a == 1 ? -1 : INF;
l = length(b, a % b);
return l == INF ? INF : l + a / b;
}
void print(int a, int b) {
if (a < b)
print(a, b - a), printf("0 ");
else if (a > b)
print(a - b, b), printf("1 ");
}
int main() {
int t;
scanf("%d", &t);
while (t--) {
int n, a, a_, k, l, l_;
scanf("%d", &n), n += 2;
k = 0, l_ = n, a_ = 0;
for (a = 1; a < n; a++) {
l = length(a, n - a);
if (l != INF) {
k++;
if (l_ > l)
l_ = l, a_ = a;
}
}
printf("%d\n", k);
print(a_, n - a_), printf("\n");
}
return 0;
}Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
