/*#pragma GCC optimize("O3")
#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")*/
#include <bits/stdc++.h>
//#define file(data) freopen(data".in", "r", stdin); freopen(data".out", "w", stdout);
#define pb push_back
#define all(data) data.begin(), data.end()
#define endl '\n'
using namespace std;
const int N = 2e4 + 5;
int t, n, m;
main() {
//file("pieaters");
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> t;
while(t--) {
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 << " ";
}
} else {
cout << m - 1 << endl;
for(int i = 1; i < m; i++) {
cout << -1 << " ";
}
}
cout << endl;
} else if(min(n, m) == 2 || 1){
cout << max(n, m) << endl;
vector < int > v;
if(n == 2) {
for(int i = 1; i <= m; i++) {
if(i % 2) cout << m - 1 << " ";
else cout << -m << " ";
}
} else {
for(int i = 1; i <= n; i++) {
if(i % 2 == 0) cout << n + 1 << " ";
else cout << -n << " ";
}
}
cout << endl;
}
}
}
Compilation message
sequence.cpp:18:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
18 | main() {
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Ok |
2 |
Correct |
0 ms |
204 KB |
Ok |
3 |
Correct |
0 ms |
204 KB |
Ok |
4 |
Correct |
1 ms |
204 KB |
Ok |
5 |
Correct |
1 ms |
204 KB |
Ok |
6 |
Correct |
1 ms |
204 KB |
Ok |
7 |
Correct |
0 ms |
204 KB |
Ok |
8 |
Correct |
1 ms |
284 KB |
Ok |
9 |
Correct |
0 ms |
204 KB |
Ok |
10 |
Correct |
1 ms |
204 KB |
Ok |
11 |
Correct |
1 ms |
204 KB |
Ok |
12 |
Correct |
1 ms |
204 KB |
Ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Ok |
2 |
Correct |
0 ms |
204 KB |
Ok |
3 |
Correct |
0 ms |
204 KB |
Ok |
4 |
Correct |
1 ms |
204 KB |
Ok |
5 |
Correct |
0 ms |
204 KB |
Ok |
6 |
Correct |
2 ms |
332 KB |
Ok |
7 |
Correct |
7 ms |
660 KB |
Ok |
8 |
Correct |
3 ms |
460 KB |
Ok |
9 |
Correct |
8 ms |
716 KB |
Ok |
10 |
Correct |
4 ms |
460 KB |
Ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Ok |
2 |
Correct |
0 ms |
204 KB |
Ok |
3 |
Correct |
0 ms |
204 KB |
Ok |
4 |
Incorrect |
0 ms |
204 KB |
Jury has the better answer : jans = 9, pans = 8 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
204 KB |
Jury has the better answer : jans = 5, pans = 4 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Ok |
2 |
Correct |
0 ms |
204 KB |
Ok |
3 |
Correct |
0 ms |
204 KB |
Ok |
4 |
Correct |
1 ms |
204 KB |
Ok |
5 |
Correct |
1 ms |
204 KB |
Ok |
6 |
Correct |
1 ms |
204 KB |
Ok |
7 |
Correct |
0 ms |
204 KB |
Ok |
8 |
Correct |
1 ms |
284 KB |
Ok |
9 |
Correct |
0 ms |
204 KB |
Ok |
10 |
Correct |
1 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 |
Incorrect |
0 ms |
204 KB |
Jury has the better answer : jans = 9, pans = 8 |
17 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Ok |
2 |
Correct |
0 ms |
204 KB |
Ok |
3 |
Correct |
0 ms |
204 KB |
Ok |
4 |
Correct |
1 ms |
204 KB |
Ok |
5 |
Correct |
1 ms |
204 KB |
Ok |
6 |
Correct |
1 ms |
204 KB |
Ok |
7 |
Correct |
0 ms |
204 KB |
Ok |
8 |
Correct |
1 ms |
284 KB |
Ok |
9 |
Correct |
0 ms |
204 KB |
Ok |
10 |
Correct |
1 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 |
Correct |
1 ms |
204 KB |
Ok |
17 |
Correct |
0 ms |
204 KB |
Ok |
18 |
Correct |
2 ms |
332 KB |
Ok |
19 |
Correct |
7 ms |
660 KB |
Ok |
20 |
Correct |
3 ms |
460 KB |
Ok |
21 |
Correct |
8 ms |
716 KB |
Ok |
22 |
Correct |
4 ms |
460 KB |
Ok |
23 |
Correct |
0 ms |
204 KB |
Ok |
24 |
Correct |
0 ms |
204 KB |
Ok |
25 |
Correct |
0 ms |
204 KB |
Ok |
26 |
Incorrect |
0 ms |
204 KB |
Jury has the better answer : jans = 9, pans = 8 |
27 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Ok |
2 |
Correct |
0 ms |
204 KB |
Ok |
3 |
Correct |
0 ms |
204 KB |
Ok |
4 |
Correct |
1 ms |
204 KB |
Ok |
5 |
Correct |
1 ms |
204 KB |
Ok |
6 |
Correct |
1 ms |
204 KB |
Ok |
7 |
Correct |
0 ms |
204 KB |
Ok |
8 |
Correct |
1 ms |
284 KB |
Ok |
9 |
Correct |
0 ms |
204 KB |
Ok |
10 |
Correct |
1 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 |
Correct |
1 ms |
204 KB |
Ok |
17 |
Correct |
0 ms |
204 KB |
Ok |
18 |
Correct |
2 ms |
332 KB |
Ok |
19 |
Correct |
7 ms |
660 KB |
Ok |
20 |
Correct |
3 ms |
460 KB |
Ok |
21 |
Correct |
8 ms |
716 KB |
Ok |
22 |
Correct |
4 ms |
460 KB |
Ok |
23 |
Correct |
0 ms |
204 KB |
Ok |
24 |
Correct |
0 ms |
204 KB |
Ok |
25 |
Correct |
0 ms |
204 KB |
Ok |
26 |
Incorrect |
0 ms |
204 KB |
Jury has the better answer : jans = 9, pans = 8 |
27 |
Halted |
0 ms |
0 KB |
- |