제출 #129473

#제출 시각아이디문제언어결과실행 시간메모리
129473E869120Binary Subsequences (info1cup17_binary)C++14
0 / 100
1057 ms4228 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; 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; }

컴파일 시 표준 에러 (stderr) 메시지

binary.cpp: In function 'int main()':
binary.cpp:40:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for (int j = 0; j < str.size(); j++) {
                   ~~^~~~~~~~~~~~
binary.cpp:41:4: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
    if (j) cout << " "; cout << str[j];
    ^~
binary.cpp:41:24: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
    if (j) cout << " "; cout << str[j];
                        ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...