# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
781803 | Trunkty | Binary Subsequences (info1cup17_binary) | C++14 | 740 ms | 360 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;
typedef long long ll;
#define int ll
int t;
int curr;
vector<int> v;
bool check(int a, int b, bool c){
if(a>b){
swap(a,b);
}
if(a==b){
if(a==0){
return true;
}
else{
return false;
}
}
else{
int p = b/(a+1);
if(c){
v.push_back(p);
}
curr += p;
b -= p*(a+1);
return check(b,a,c);
}
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cin >> t;
for(int i=1;i<=t;i++){
int n;
cin >> n;
int ans=0,mini=2e9,pos;
for(int i=0;i<=n;i++){
curr = 0;
if(check(i,n-i,false)){
ans++;
if(curr<mini){
mini = curr;
pos = i;
}
}
}
cout << ans << "\n";
v.clear();
check(pos,n-pos,true);
reverse(v.begin(),v.end());
for(int i=0;i<v.size();i++){
for(int j=1;j<=v[i];j++){
cout << i%2 << " ";
}
}
cout << "\n";
}
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... |