Submission #98556

#TimeUsernameProblemLanguageResultExecution timeMemory
98556TAMREFBinary Subsequences (info1cup17_binary)C++11
100 / 100
551 ms512 KiB
#include <bits/stdc++.h> using namespace std; int t, k; void pro(int k){ int cnt = 0; int len = INT_MAX, lenx = 0; for(int i = 0; i + i < k; i++){ int x = i, y = k - x; int nlen = 0; while(x){ if(x == y){ nlen = INT_MAX; break; } nlen += y / (x+1); y %= (x+1); swap(x,y); } if(nlen < INT_MAX) cnt += 2, nlen += y; if(nlen < len){ len = nlen; lenx = i; } } cout << cnt << '\n'; int X = lenx, Y = k - X; while(X || Y){ cout << (X < Y) << ' '; if(X < Y) Y -= (X+1); else X -= (Y+1); } cout << '\n'; } int main(){ ios_base::sync_with_stdio(0);cin.tie(0); for(cin >> t; t--;){ cin >> k; pro(k); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...