Submission #683817

#TimeUsernameProblemLanguageResultExecution timeMemory
683817luka1234Nice sequence (IZhO18_sequence)C++14
15 / 100
11 ms684 KiB
#include<bits/stdc++.h> #define ll long long #define ff first #define ss second #define db double using namespace std; int main(){ int t; cin>>t; while(t--){ int n,m; cin>>n>>m; if(n==2&&m==3){ cout<<3<<"\n"; cout<<"3 -4 2"; cout<<"\n"; continue; } if(n%m==0||m%n==0){ if(n>=m){ cout<<n-1<<"\n"; for(int k=1;k<n;k++) cout<<1<<' '; cout<<"\n"; } else{ cout<<m-1<<"\n"; for(int k=1;k<m;k++) cout<<-1<<' '; cout<<"\n"; } continue; } if(min(n,m)==2){ int ans[max(m,n)+1]; if(n==2){ cout<<m<<"\n"; for(int k=1;k<=m;k+=2) ans[k]=m-1; for(int k=2;k<=m;k+=2) ans[k]=-m; } else{ cout<<n<<"\n"; for(int k=1;k<=n;k+=2) ans[k]=-n+1; for(int k=2;k<=n;k+=2) ans[k]=n; } for(int k=1;k<=max(m,n);k++) cout<<ans[k]<<' '; cout<<"\n"; } } 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...