| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 67936 | yusufake | Binary Subsequences (info1cup17_binary) | C++98 | 718 ms | 576 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; 
#define pb push_back
#define mp make_pair
#define st first
#define nd second
typedef long long ll; 
typedef pair < int , int > pp; 
const int mod = 1e9 + 7; 
const int N   = 2e6 + 6; 
pair < int , pp > ans;
int f(int x, int y){
    if(x < y) swap(x,y); 
    int a=x; int b=y;
    int t;
    int zz=0;
    for(; y ;){
        t = x%y;
        zz += x/y;
        x = y;
        y = t;
    }
    if(x==1)
        ans = min(ans , mp(zz,mp(a,b)));
    return x == 1;
}
int ww,k,t,i,x,y,zz,h;
int main(){
    scanf("%d",&ww);
    for(;ww--; puts("")){
        scanf("%d",&k);
        k += 2;
        t = 0;
        ans.st = mod;
        zz = k/2;
        for(i=1;i<=zz;i++){
            t += 2*f(i,k-i);
        }
        if(k%2==0) t -= f(zz,zz);
        printf("%d\n",t);
        x = ans.nd.st;
        y = ans.nd.nd;
        for(; y ; h=!h){
        t = x%y;
        zz = x/y;
        if(!t) zz--;
        for(;zz--;) printf("%d ",h);
        x = y;
        y = t;
    }
    
    }
    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... | ||||
