#include <bits/stdc++.h>
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)
#define all(a) a.begin() , a.end()
#define F first
#define S second
using namespace std;
using ll = long long;
const int N = 2e5+5 , inf = 2e9 + 7;
const ll INF = 1e18 , mod = 1e9+7 , P = 6547;
void solve(int tc) {
int n, m;
cin >> n >> m;
int coef = 1;
if(n > m) {
swap(n , m);
coef *= -1;
}
if(m % n == 0) {
cout << m-1 << '\n';
for(int i = 1; i < m; i ++) {
cout << (-1)*coef << ' ';
}
cout << '\n';
// return;c
return;
}
int mx = 9e8;
int psv = mx/(n-1);
int otr = -psv*(n-1)-1;
if(n == 3 && m == 8) {
assert(0);
}
if(m/n == 1) {
cout << 2*n-1 << '\n';
for(int i = 1; i < 2*n; i ++) {
if(i%n == 0) {
cout << otr*coef << ' ';
}
else {
cout << psv*coef << ' ';
}
}
cout << '\n';
return;
}
cout << m << '\n';
for(int i = 1; i <= m; i ++) {
if(i%n == 0) {
cout << otr*coef << ' ';
}
else {
cout << psv*coef << ' ';
}
}
cout << '\n';
}
/*
3 3 3 -10 3 3
*/
main() {
ios;
int tt = 1 , tc = 0;
cin >> tt;
while(tt --) {
solve(++tc);
}
return 0;
}
Compilation message
sequence.cpp:65:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
65 | main() {
| ^~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Ok |
2 |
Correct |
0 ms |
212 KB |
Ok |
3 |
Correct |
1 ms |
320 KB |
Ok |
4 |
Correct |
0 ms |
212 KB |
Ok |
5 |
Correct |
1 ms |
212 KB |
Ok |
6 |
Correct |
1 ms |
212 KB |
Ok |
7 |
Correct |
1 ms |
212 KB |
Ok |
8 |
Correct |
1 ms |
212 KB |
Ok |
9 |
Correct |
1 ms |
212 KB |
Ok |
10 |
Correct |
1 ms |
324 KB |
Ok |
11 |
Correct |
0 ms |
212 KB |
Ok |
12 |
Correct |
1 ms |
212 KB |
Ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
316 KB |
Ok |
2 |
Correct |
1 ms |
212 KB |
Ok |
3 |
Correct |
1 ms |
212 KB |
Ok |
4 |
Correct |
1 ms |
212 KB |
Ok |
5 |
Correct |
1 ms |
212 KB |
Ok |
6 |
Correct |
2 ms |
340 KB |
Ok |
7 |
Correct |
7 ms |
756 KB |
Ok |
8 |
Correct |
4 ms |
468 KB |
Ok |
9 |
Correct |
8 ms |
852 KB |
Ok |
10 |
Correct |
5 ms |
708 KB |
Ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Ok |
2 |
Correct |
0 ms |
212 KB |
Ok |
3 |
Correct |
0 ms |
212 KB |
Ok |
4 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Jury has the better answer : jans = 6, pans = 5 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Ok |
2 |
Correct |
0 ms |
212 KB |
Ok |
3 |
Correct |
1 ms |
320 KB |
Ok |
4 |
Correct |
0 ms |
212 KB |
Ok |
5 |
Correct |
1 ms |
212 KB |
Ok |
6 |
Correct |
1 ms |
212 KB |
Ok |
7 |
Correct |
1 ms |
212 KB |
Ok |
8 |
Correct |
1 ms |
212 KB |
Ok |
9 |
Correct |
1 ms |
212 KB |
Ok |
10 |
Correct |
1 ms |
324 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 |
0 ms |
212 KB |
Ok |
15 |
Correct |
0 ms |
212 KB |
Ok |
16 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
17 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Ok |
2 |
Correct |
0 ms |
212 KB |
Ok |
3 |
Correct |
1 ms |
320 KB |
Ok |
4 |
Correct |
0 ms |
212 KB |
Ok |
5 |
Correct |
1 ms |
212 KB |
Ok |
6 |
Correct |
1 ms |
212 KB |
Ok |
7 |
Correct |
1 ms |
212 KB |
Ok |
8 |
Correct |
1 ms |
212 KB |
Ok |
9 |
Correct |
1 ms |
212 KB |
Ok |
10 |
Correct |
1 ms |
324 KB |
Ok |
11 |
Correct |
0 ms |
212 KB |
Ok |
12 |
Correct |
1 ms |
212 KB |
Ok |
13 |
Correct |
0 ms |
316 KB |
Ok |
14 |
Correct |
1 ms |
212 KB |
Ok |
15 |
Correct |
1 ms |
212 KB |
Ok |
16 |
Correct |
1 ms |
212 KB |
Ok |
17 |
Correct |
1 ms |
212 KB |
Ok |
18 |
Correct |
2 ms |
340 KB |
Ok |
19 |
Correct |
7 ms |
756 KB |
Ok |
20 |
Correct |
4 ms |
468 KB |
Ok |
21 |
Correct |
8 ms |
852 KB |
Ok |
22 |
Correct |
5 ms |
708 KB |
Ok |
23 |
Correct |
1 ms |
212 KB |
Ok |
24 |
Correct |
0 ms |
212 KB |
Ok |
25 |
Correct |
0 ms |
212 KB |
Ok |
26 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
27 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Ok |
2 |
Correct |
0 ms |
212 KB |
Ok |
3 |
Correct |
1 ms |
320 KB |
Ok |
4 |
Correct |
0 ms |
212 KB |
Ok |
5 |
Correct |
1 ms |
212 KB |
Ok |
6 |
Correct |
1 ms |
212 KB |
Ok |
7 |
Correct |
1 ms |
212 KB |
Ok |
8 |
Correct |
1 ms |
212 KB |
Ok |
9 |
Correct |
1 ms |
212 KB |
Ok |
10 |
Correct |
1 ms |
324 KB |
Ok |
11 |
Correct |
0 ms |
212 KB |
Ok |
12 |
Correct |
1 ms |
212 KB |
Ok |
13 |
Correct |
0 ms |
316 KB |
Ok |
14 |
Correct |
1 ms |
212 KB |
Ok |
15 |
Correct |
1 ms |
212 KB |
Ok |
16 |
Correct |
1 ms |
212 KB |
Ok |
17 |
Correct |
1 ms |
212 KB |
Ok |
18 |
Correct |
2 ms |
340 KB |
Ok |
19 |
Correct |
7 ms |
756 KB |
Ok |
20 |
Correct |
4 ms |
468 KB |
Ok |
21 |
Correct |
8 ms |
852 KB |
Ok |
22 |
Correct |
5 ms |
708 KB |
Ok |
23 |
Correct |
1 ms |
212 KB |
Ok |
24 |
Correct |
0 ms |
212 KB |
Ok |
25 |
Correct |
0 ms |
212 KB |
Ok |
26 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 6 |
27 |
Halted |
0 ms |
0 KB |
- |