#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
#include <stack>
#include <string>
#include <map>
#include <queue>
using namespace std;
const long long oo = 1000000000000000000;
long long int sum, ans = 0, mx = 0, mn = 1000000000, num, pos;
/*
ViHHiPuh
(( `'-""``""-'` ))
)-__-_.._-__-(
/ --- (o _ o) --- \
\ .-* ( .0. ) *-. /
_'-. ,_ '=' _, .-'_
/ `;#'#'# - #'#'#;` \
\_)) -----'#'----- ((_/
# --------- #
'# ------- ------ #'
/..-'# ------- #'-.\
_\...-\'# -- #'/-.../_
((____)- '#' -(____))
cout << fixed << setprecision(6) << x;
freopen ( "sum.in", "r", stdin )
*/
vector <int> v;
int a[ 200001 ], n, m;
int main () {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int t;
cin >> t;
while ( t -- ) {
cin >> n >> m;
mn = min( n, m );
mx = max( n, m );
if ( n % m == 0 || m % n == 0 ) {
if ( n > m ) {
cout << n - 1 << "\n";
for ( int i = 1; i < n; i ++ )
cout << 1 << " ";
}
else {
cout << m - 1 << "\n";
for ( int i = 1; i < m; i ++ )
cout << -1 << " ";
}
cout << "\n";
}
else if ( min( n, m ) == 2 ) {
cout << max( n, m ) << "\n";
mx = max( n, m );
if ( n == 2 ) {
for ( int i = 1; i <= mx; i ++ ) {
if ( i % 2 )
cout << mx << " ";
else
cout << ( mx * -1 ) - 1 << " ";
}
cout << "\n";
}
else {
for ( int i = 1; i <= mx; i ++ ) {
if ( i % 2 == 0 )
cout << mx + 1 << " ";
else
cout << ( mx * -1 ) << " ";
}
cout << "\n";
}
}
else {
cout << mx + 1 << "\n";
}
}
}
/*
3 4
3 5 -9 2
2 2 -5 2 2
3 5
-3 5 -3 -3 5 -3
0 0 0 0 0 0
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Ok |
2 |
Correct |
0 ms |
204 KB |
Ok |
3 |
Correct |
1 ms |
204 KB |
Ok |
4 |
Correct |
0 ms |
204 KB |
Ok |
5 |
Correct |
1 ms |
204 KB |
Ok |
6 |
Correct |
1 ms |
204 KB |
Ok |
7 |
Correct |
1 ms |
204 KB |
Ok |
8 |
Correct |
1 ms |
204 KB |
Ok |
9 |
Correct |
1 ms |
204 KB |
Ok |
10 |
Correct |
0 ms |
204 KB |
Ok |
11 |
Correct |
1 ms |
204 KB |
Ok |
12 |
Correct |
1 ms |
204 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Ok |
2 |
Correct |
0 ms |
204 KB |
Ok |
3 |
Correct |
0 ms |
204 KB |
Ok |
4 |
Correct |
0 ms |
204 KB |
Ok |
5 |
Correct |
0 ms |
204 KB |
Ok |
6 |
Correct |
2 ms |
332 KB |
Ok |
7 |
Correct |
6 ms |
588 KB |
Ok |
8 |
Correct |
4 ms |
460 KB |
Ok |
9 |
Correct |
7 ms |
716 KB |
Ok |
10 |
Correct |
4 ms |
460 KB |
Ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Ok |
2 |
Correct |
0 ms |
204 KB |
Ok |
3 |
Correct |
0 ms |
204 KB |
Ok |
4 |
Incorrect |
1 ms |
204 KB |
there is incorrect sequence |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
there is incorrect sequence |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Ok |
2 |
Correct |
0 ms |
204 KB |
Ok |
3 |
Correct |
1 ms |
204 KB |
Ok |
4 |
Correct |
0 ms |
204 KB |
Ok |
5 |
Correct |
1 ms |
204 KB |
Ok |
6 |
Correct |
1 ms |
204 KB |
Ok |
7 |
Correct |
1 ms |
204 KB |
Ok |
8 |
Correct |
1 ms |
204 KB |
Ok |
9 |
Correct |
1 ms |
204 KB |
Ok |
10 |
Correct |
0 ms |
204 KB |
Ok |
11 |
Correct |
1 ms |
204 KB |
Ok |
12 |
Correct |
1 ms |
204 KB |
Ok |
13 |
Correct |
1 ms |
204 KB |
Ok |
14 |
Correct |
0 ms |
204 KB |
Ok |
15 |
Correct |
0 ms |
204 KB |
Ok |
16 |
Incorrect |
1 ms |
204 KB |
there is incorrect sequence |
17 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Ok |
2 |
Correct |
0 ms |
204 KB |
Ok |
3 |
Correct |
1 ms |
204 KB |
Ok |
4 |
Correct |
0 ms |
204 KB |
Ok |
5 |
Correct |
1 ms |
204 KB |
Ok |
6 |
Correct |
1 ms |
204 KB |
Ok |
7 |
Correct |
1 ms |
204 KB |
Ok |
8 |
Correct |
1 ms |
204 KB |
Ok |
9 |
Correct |
1 ms |
204 KB |
Ok |
10 |
Correct |
0 ms |
204 KB |
Ok |
11 |
Correct |
1 ms |
204 KB |
Ok |
12 |
Correct |
1 ms |
204 KB |
Ok |
13 |
Correct |
0 ms |
204 KB |
Ok |
14 |
Correct |
0 ms |
204 KB |
Ok |
15 |
Correct |
0 ms |
204 KB |
Ok |
16 |
Correct |
0 ms |
204 KB |
Ok |
17 |
Correct |
0 ms |
204 KB |
Ok |
18 |
Correct |
2 ms |
332 KB |
Ok |
19 |
Correct |
6 ms |
588 KB |
Ok |
20 |
Correct |
4 ms |
460 KB |
Ok |
21 |
Correct |
7 ms |
716 KB |
Ok |
22 |
Correct |
4 ms |
460 KB |
Ok |
23 |
Correct |
1 ms |
204 KB |
Ok |
24 |
Correct |
0 ms |
204 KB |
Ok |
25 |
Correct |
0 ms |
204 KB |
Ok |
26 |
Incorrect |
1 ms |
204 KB |
there is incorrect sequence |
27 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Ok |
2 |
Correct |
0 ms |
204 KB |
Ok |
3 |
Correct |
1 ms |
204 KB |
Ok |
4 |
Correct |
0 ms |
204 KB |
Ok |
5 |
Correct |
1 ms |
204 KB |
Ok |
6 |
Correct |
1 ms |
204 KB |
Ok |
7 |
Correct |
1 ms |
204 KB |
Ok |
8 |
Correct |
1 ms |
204 KB |
Ok |
9 |
Correct |
1 ms |
204 KB |
Ok |
10 |
Correct |
0 ms |
204 KB |
Ok |
11 |
Correct |
1 ms |
204 KB |
Ok |
12 |
Correct |
1 ms |
204 KB |
Ok |
13 |
Correct |
0 ms |
204 KB |
Ok |
14 |
Correct |
0 ms |
204 KB |
Ok |
15 |
Correct |
0 ms |
204 KB |
Ok |
16 |
Correct |
0 ms |
204 KB |
Ok |
17 |
Correct |
0 ms |
204 KB |
Ok |
18 |
Correct |
2 ms |
332 KB |
Ok |
19 |
Correct |
6 ms |
588 KB |
Ok |
20 |
Correct |
4 ms |
460 KB |
Ok |
21 |
Correct |
7 ms |
716 KB |
Ok |
22 |
Correct |
4 ms |
460 KB |
Ok |
23 |
Correct |
1 ms |
204 KB |
Ok |
24 |
Correct |
0 ms |
204 KB |
Ok |
25 |
Correct |
0 ms |
204 KB |
Ok |
26 |
Incorrect |
1 ms |
204 KB |
there is incorrect sequence |
27 |
Halted |
0 ms |
0 KB |
- |