Submission #1127714

#TimeUsernameProblemLanguageResultExecution timeMemory
1127714boris_7Nice sequence (IZhO18_sequence)C++20
15 / 100
6 ms840 KiB
#include<bits/stdc++.h> using namespace std; using ll = long long; int mx = 1e8; void solve(){ int n,m; cin>>n>>m; if(max(n,m)%min(n,m)==0){ if(n>m){ cout<<n-1<<endl; for(int i = 1;i<n;i++) cout<<1<<" "; cout<<endl; } else{ cout<<m-1<<endl; for(int i = 1;i<m;i++) cout<<-1<<" "; cout<<endl; } } else if(min(n,m)==2){ if(n>m){ cout<<n<<endl; for(int i = 1;i<=n;i++) { if(i%2==0) cout<<mx<<" "; else cout<<-mx+1<<" "; } } else{ cout<<m<<endl; for(int i = 1;i<=m;i++) { if(i%2==0) cout<<-mx<<" "; else cout<<mx-1<<" "; } } } else{ if(n-m==1){ cout<<n<<endl; int sum = 4*(n-2); cout<<1-sum<<" "; for(int i = 2;i<n;i++){ cout<<4<<" "; } cout<<1-sum<<endl; } else if(m-n==1){ cout<<m<<endl; int sum = 4*(m-2); cout<<sum-1<<" "; for(int i = 2;i<m;i++){ cout<<-4<<" "; } cout<<sum-1<<endl; } else if(n-m==2){ cout<<n<<endl; for(int i = 0;i<n;i++){ if(i%m==0) cout<<-(m-1)*100+1<<" "; else cout<<100<<" "; } cout<<endl; } else{ cout<<m<<endl; for(int i = 0;i<m;i++){ if(i%n==0) cout<<(n-1)*100-1<<" "; else cout<<-100<<" "; } cout<<endl; } } } signed main(){ ios_base::sync_with_stdio(0); cin.tie(nullptr); int t;cin>>t;while(t--) solve(); }
#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...