Submission #129479

#TimeUsernameProblemLanguageResultExecution timeMemory
129479E869120Binary Subsequences (info1cup17_binary)C++14
82 / 100
1057 ms504 KiB
#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; long long cnt = 0, ret = (1 << 30), mask = 0; for (int j = 1; j <= A + 2; j++) { if (gcd(j, A + 2) >= 2) continue; cnt++; int t1 = j, t2 = (A + 2) - j; long long mask1 = 0, lens = 0; while (t1 >= 1 && t2 >= 1) { if (t1 < t2) { t2 -= t1; } else { mask1 += (1LL << lens); t1 -= t2; } lens++; } if (ret > lens) { ret = lens; mask = mask1; } } cout << cnt << endl; for (int j = 0; j < ret - 1; j++) { if (j) cout << " "; cout << (mask / (1LL << j)) % 2; } cout << endl; } return 0; }

Compilation message (stderr)

binary.cpp: In function 'int main()':
binary.cpp:40:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
    if (j) cout << " "; cout << (mask / (1LL << j)) % 2;
    ^~
binary.cpp:40:24: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
    if (j) cout << " "; cout << (mask / (1LL << j)) % 2;
                        ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...