#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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Ok |
2 |
Correct |
0 ms |
316 KB |
Ok |
3 |
Correct |
1 ms |
316 KB |
Ok |
4 |
Correct |
1 ms |
212 KB |
Ok |
5 |
Correct |
1 ms |
212 KB |
Ok |
6 |
Correct |
1 ms |
212 KB |
Ok |
7 |
Correct |
1 ms |
320 KB |
Ok |
8 |
Correct |
0 ms |
324 KB |
Ok |
9 |
Correct |
0 ms |
212 KB |
Ok |
10 |
Correct |
1 ms |
320 KB |
Ok |
11 |
Correct |
0 ms |
212 KB |
Ok |
12 |
Correct |
1 ms |
212 KB |
Ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
there is incorrect sequence |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Ok |
2 |
Correct |
1 ms |
212 KB |
Ok |
3 |
Incorrect |
0 ms |
212 KB |
there is incorrect sequence |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
there is incorrect sequence |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Ok |
2 |
Correct |
0 ms |
316 KB |
Ok |
3 |
Correct |
1 ms |
316 KB |
Ok |
4 |
Correct |
1 ms |
212 KB |
Ok |
5 |
Correct |
1 ms |
212 KB |
Ok |
6 |
Correct |
1 ms |
212 KB |
Ok |
7 |
Correct |
1 ms |
320 KB |
Ok |
8 |
Correct |
0 ms |
324 KB |
Ok |
9 |
Correct |
0 ms |
212 KB |
Ok |
10 |
Correct |
1 ms |
320 KB |
Ok |
11 |
Correct |
0 ms |
212 KB |
Ok |
12 |
Correct |
1 ms |
212 KB |
Ok |
13 |
Correct |
1 ms |
212 KB |
Ok |
14 |
Correct |
1 ms |
212 KB |
Ok |
15 |
Incorrect |
0 ms |
212 KB |
there is incorrect sequence |
16 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Ok |
2 |
Correct |
0 ms |
316 KB |
Ok |
3 |
Correct |
1 ms |
316 KB |
Ok |
4 |
Correct |
1 ms |
212 KB |
Ok |
5 |
Correct |
1 ms |
212 KB |
Ok |
6 |
Correct |
1 ms |
212 KB |
Ok |
7 |
Correct |
1 ms |
320 KB |
Ok |
8 |
Correct |
0 ms |
324 KB |
Ok |
9 |
Correct |
0 ms |
212 KB |
Ok |
10 |
Correct |
1 ms |
320 KB |
Ok |
11 |
Correct |
0 ms |
212 KB |
Ok |
12 |
Correct |
1 ms |
212 KB |
Ok |
13 |
Incorrect |
1 ms |
212 KB |
there is incorrect sequence |
14 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Ok |
2 |
Correct |
0 ms |
316 KB |
Ok |
3 |
Correct |
1 ms |
316 KB |
Ok |
4 |
Correct |
1 ms |
212 KB |
Ok |
5 |
Correct |
1 ms |
212 KB |
Ok |
6 |
Correct |
1 ms |
212 KB |
Ok |
7 |
Correct |
1 ms |
320 KB |
Ok |
8 |
Correct |
0 ms |
324 KB |
Ok |
9 |
Correct |
0 ms |
212 KB |
Ok |
10 |
Correct |
1 ms |
320 KB |
Ok |
11 |
Correct |
0 ms |
212 KB |
Ok |
12 |
Correct |
1 ms |
212 KB |
Ok |
13 |
Incorrect |
1 ms |
212 KB |
there is incorrect sequence |
14 |
Halted |
0 ms |
0 KB |
- |