# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
129473 | E869120 | Binary Subsequences (info1cup17_binary) | C++14 | 1057 ms | 4228 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 <iostream>
#include <algorithm>
using namespace std;
int gcd(int a, int b) {
if (b == 0) return a;
return gcd(b, a%b);
}
int euler(int pos) {
int cnt = 0;
for (int i = 1; i <= pos; i++) {
if (gcd(i, pos) == 1) cnt++;
}
return cnt;
}
int main() {
int T; cin >> T;
for (int i = 1; i <= T; i++) {
int A; cin >> A;
cout << euler(A + 2) << endl;
string str = "";
for (int j = 1; j <= A + 2; j++) {
if (gcd(j, A + 2) >= 2) continue;
int t1 = j, t2 = (A + 2) - j; string V = "";
while (t1 >= 1 && t2 >= 1) {
if (t1 < t2) {
V += "0"; t2 -= t1;
}
else {
V += "1"; t1 -= t2;
}
}
V = V.substr(0, V.size() - 1);
if (str == "" || V.size() < str.size()) str = V;
}
for (int j = 0; j < str.size(); j++) {
if (j) cout << " "; cout << str[j];
}
cout << endl;
}
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... |