Submission #172728

#TimeUsernameProblemLanguageResultExecution timeMemory
172728mosiashvililukaNice sequence (IZhO18_sequence)C++14
15 / 100
10 ms888 KiB
#include<bits/stdc++.h> using namespace std; long long a,b,c,d,e,tes,t,n,m,zx,cnst=50000,p[1000009],pi,jm[1000009]; int main(){ ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0); cin>>tes; for(t=1; t<=tes; t++){ cin>>n>>m; if(n<m){ swap(n,m); zx=-1; }else{ zx=1; } if(n%m==0||m==2){ if(n%m==0){ cout<<n-1<<endl; if(n!=1){ for(b=1; b<n; b++){ cout<<zx<<" "; } cout<<endl; } }else{ cout<<n<<endl; for(b=1; b<=n; b++){ if(b%2==0) cout<<zx*1000000<<" "; else cout<<-zx*999999<<" "; } cout<<endl; } continue; } while(1){ pi++; if(pi%m==0){ p[pi]=zx*cnst*(m-1)-zx; }else{ p[pi]=-zx*cnst; } jm[pi]=jm[pi-1]+p[pi]; if(pi>=n){ if(jm[pi]-jm[pi-n]==-abs(jm[pi]-jm[pi-n])*zx){ }else{ pi--; break; } } } cout<<pi<<endl; for(c=1; c<=pi; c++) cout<<p[c]<<" "; cout<<endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...