Submission #67933

#TimeUsernameProblemLanguageResultExecution timeMemory
67933yusufakeBinary Subsequences (info1cup17_binary)C++98
82 / 100
1085 ms580 KiB
#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; for(i=1;i<k;i++){ t += f(i,k-i); } 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)

binary.cpp: In function 'int main()':
binary.cpp:34:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&ww);
     ~~~~~^~~~~~~~~~
binary.cpp:36:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&k);
         ~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...