# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
782030 | Andrey | Binary Subsequences (info1cup17_binary) | C++14 | 590 ms | 364 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 <bits/stdc++.h>
using namespace std;
void solve() {
int k,ans = 0,a = 0,b = 0,br = 0,sm = INT_MAX,c;
cin >> k;
for(int i = 0; i <= k; i++) {
a = i;
b = k-i;
br = 0;
while(a != b) {
if(a < b) {
swap(a,b);
}
br+=a/(b+1);
a%=b+1;
}
if(a == 0 && b == 0) {
ans++;
if(br < sm) {
sm = br;
c = i;
}
}
}
vector<int> wut(0);
a = c;
b = k-c;
while(a != b) {
if(a > b) {
wut.push_back(0);
a-=b+1;
}
else {
wut.push_back(1);
b-=a+1;
}
}
cout << ans << "\n";
for(int i = 0; i < wut.size(); i++) {
cout << wut[i] << " ";
}
cout << "\n";
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while(t--) {
solve();
}
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... |