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"
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define int long long
#define spc " "
#define nd "\n"
#define all(a) a.begin(),a.end()
#define nm 200005
#define rep(b,a) for(int b=0;b<a;b++)
#define REP(b,a) for(int b=1;b<=a;b++)
#define inf 1e18
using namespace std;
void solve(){
int n, m;
cin>>n>>m;
int x=5;
if(n==m){
cout<<n-1<<nd;
rep(i, n-1)cout<<5<<spc;
cout<<nd;
return;
}
else if(n<m){
int k=(m/n)*n+n*(!!(m%n))-1;
cout<<k<<nd;
REP(i, k){
if(i%n==0){
cout<<(-n+1)*x-1<<spc;
}
else cout<<x<<spc;
}
cout<<nd;
}
else{
int k=(n/m)*m+m*(!!(n%m))-1;
cout<<k<<nd;
REP(i, k){
if(i%m==0){
cout<<(m+1)*x+1<<spc;
}
else cout<<-x<<spc;
}
cout<<nd;
}
}
int32_t main(){
fast
#ifdef Local
freopen("in","r",stdin);
freopen("out","w",stdout);
#endif
int t;
cin>>t;
while(t--)
solve();
#ifdef Local
cout<<endl<<fixed<<setprecision(2)<<1000.0 * clock() / CLOCKS_PER_SEC<< " milliseconds ";
#endif
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |