//-------------dilanyan------------\\
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
//------------------KarginDefines--------------------\\
#define ll long long
#define pb push_back
#define all(u) (u).begin(), (u).end()
#define pqueue priority_queue
#define upper upper_bound
#define lower lower_bound
#define umap unordered_map
#define uset unordered_set
#define Kargin ios_base::sync_with_stdio(false);cin.tie(NULL);
#define Usaco freopen(".in", "r", stdin); freopen(".out", "w", stdout);
//-------------------KarginConstants------------------\\
const ll mod = 1000000007;
const ll inf = 1e18;
//-------------------KarginCode------------------------\\
const int N = 300005;
void KarginSolve() {
int n, m;
cin >> n >> m;
if (max(n, m) % min(n, m) == 0) {
cout << max(n, m) - 1 << '\n';
for (int i = 1;i < max(n, m);i++) {
if (n >= m) cout << 1 << ' ';
else cout << -1 << ' ';
}
cout << '\n';
}
else if (min(n, m) == 2) {
if (max(n, m) % 2 == 0) {
cout << max(n, m) - 1 << '\n';
for (int i = 1;i < max(n, m);i++) {
if (n == 2) cout << -1 << ' ';
else cout << 1 << '\n';
}
cout << '\n';
}
else {
int c = max(n, m) - 1;
int k = c / 2;
cout << c + 1 << '\n';
k++;
for (int i = 1;i <= c;i += 2) {
if (n == 2) cout << k << ' ' << (-k - 1) << ' ';
else cout << -k << ' ' << k + 1 << ' ';
}
if (n == 2) cout << k << '\n';
else cout << -k << '\n';
}
}
}
int main() {
//Usaco
Kargin;
int test = 1;
cin >> test;
while (test--) {
KarginSolve();
}
return 0;
}
Compilation message
sequence.cpp:1:1: warning: multi-line comment [-Wcomment]
1 | //-------------dilanyan------------\\
| ^
sequence.cpp:8:1: warning: multi-line comment [-Wcomment]
8 | //------------------KarginDefines--------------------\\
| ^
sequence.cpp:22:1: warning: multi-line comment [-Wcomment]
22 | //-------------------KarginConstants------------------\\
| ^
sequence.cpp:27:1: warning: multi-line comment [-Wcomment]
27 | //-------------------KarginCode------------------------\\
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Ok |
2 |
Correct |
0 ms |
348 KB |
Ok |
3 |
Correct |
0 ms |
348 KB |
Ok |
4 |
Correct |
0 ms |
348 KB |
Ok |
5 |
Correct |
0 ms |
452 KB |
Ok |
6 |
Correct |
0 ms |
344 KB |
Ok |
7 |
Correct |
1 ms |
348 KB |
Ok |
8 |
Correct |
0 ms |
348 KB |
Ok |
9 |
Correct |
0 ms |
348 KB |
Ok |
10 |
Correct |
1 ms |
344 KB |
Ok |
11 |
Correct |
0 ms |
348 KB |
Ok |
12 |
Correct |
0 ms |
348 KB |
Ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Ok |
2 |
Correct |
1 ms |
348 KB |
Ok |
3 |
Correct |
0 ms |
344 KB |
Ok |
4 |
Correct |
0 ms |
348 KB |
Ok |
5 |
Correct |
0 ms |
348 KB |
Ok |
6 |
Correct |
1 ms |
348 KB |
Ok |
7 |
Correct |
5 ms |
604 KB |
Ok |
8 |
Correct |
3 ms |
604 KB |
Ok |
9 |
Correct |
10 ms |
796 KB |
Ok |
10 |
Correct |
4 ms |
604 KB |
Ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Ok |
2 |
Correct |
0 ms |
348 KB |
Ok |
3 |
Correct |
1 ms |
344 KB |
Ok |
4 |
Incorrect |
0 ms |
348 KB |
Jury has the better answer : jans = 9, pans = 2 |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Unexpected end of file - int32 expected |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Ok |
2 |
Correct |
0 ms |
348 KB |
Ok |
3 |
Correct |
0 ms |
348 KB |
Ok |
4 |
Correct |
0 ms |
348 KB |
Ok |
5 |
Correct |
0 ms |
452 KB |
Ok |
6 |
Correct |
0 ms |
344 KB |
Ok |
7 |
Correct |
1 ms |
348 KB |
Ok |
8 |
Correct |
0 ms |
348 KB |
Ok |
9 |
Correct |
0 ms |
348 KB |
Ok |
10 |
Correct |
1 ms |
344 KB |
Ok |
11 |
Correct |
0 ms |
348 KB |
Ok |
12 |
Correct |
0 ms |
348 KB |
Ok |
13 |
Correct |
0 ms |
344 KB |
Ok |
14 |
Correct |
0 ms |
348 KB |
Ok |
15 |
Correct |
1 ms |
344 KB |
Ok |
16 |
Incorrect |
0 ms |
348 KB |
Jury has the better answer : jans = 9, pans = 2 |
17 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Ok |
2 |
Correct |
0 ms |
348 KB |
Ok |
3 |
Correct |
0 ms |
348 KB |
Ok |
4 |
Correct |
0 ms |
348 KB |
Ok |
5 |
Correct |
0 ms |
452 KB |
Ok |
6 |
Correct |
0 ms |
344 KB |
Ok |
7 |
Correct |
1 ms |
348 KB |
Ok |
8 |
Correct |
0 ms |
348 KB |
Ok |
9 |
Correct |
0 ms |
348 KB |
Ok |
10 |
Correct |
1 ms |
344 KB |
Ok |
11 |
Correct |
0 ms |
348 KB |
Ok |
12 |
Correct |
0 ms |
348 KB |
Ok |
13 |
Correct |
1 ms |
344 KB |
Ok |
14 |
Correct |
1 ms |
348 KB |
Ok |
15 |
Correct |
0 ms |
344 KB |
Ok |
16 |
Correct |
0 ms |
348 KB |
Ok |
17 |
Correct |
0 ms |
348 KB |
Ok |
18 |
Correct |
1 ms |
348 KB |
Ok |
19 |
Correct |
5 ms |
604 KB |
Ok |
20 |
Correct |
3 ms |
604 KB |
Ok |
21 |
Correct |
10 ms |
796 KB |
Ok |
22 |
Correct |
4 ms |
604 KB |
Ok |
23 |
Correct |
0 ms |
344 KB |
Ok |
24 |
Correct |
0 ms |
348 KB |
Ok |
25 |
Correct |
1 ms |
344 KB |
Ok |
26 |
Incorrect |
0 ms |
348 KB |
Jury has the better answer : jans = 9, pans = 2 |
27 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Ok |
2 |
Correct |
0 ms |
348 KB |
Ok |
3 |
Correct |
0 ms |
348 KB |
Ok |
4 |
Correct |
0 ms |
348 KB |
Ok |
5 |
Correct |
0 ms |
452 KB |
Ok |
6 |
Correct |
0 ms |
344 KB |
Ok |
7 |
Correct |
1 ms |
348 KB |
Ok |
8 |
Correct |
0 ms |
348 KB |
Ok |
9 |
Correct |
0 ms |
348 KB |
Ok |
10 |
Correct |
1 ms |
344 KB |
Ok |
11 |
Correct |
0 ms |
348 KB |
Ok |
12 |
Correct |
0 ms |
348 KB |
Ok |
13 |
Correct |
1 ms |
344 KB |
Ok |
14 |
Correct |
1 ms |
348 KB |
Ok |
15 |
Correct |
0 ms |
344 KB |
Ok |
16 |
Correct |
0 ms |
348 KB |
Ok |
17 |
Correct |
0 ms |
348 KB |
Ok |
18 |
Correct |
1 ms |
348 KB |
Ok |
19 |
Correct |
5 ms |
604 KB |
Ok |
20 |
Correct |
3 ms |
604 KB |
Ok |
21 |
Correct |
10 ms |
796 KB |
Ok |
22 |
Correct |
4 ms |
604 KB |
Ok |
23 |
Correct |
0 ms |
344 KB |
Ok |
24 |
Correct |
0 ms |
348 KB |
Ok |
25 |
Correct |
1 ms |
344 KB |
Ok |
26 |
Incorrect |
0 ms |
348 KB |
Jury has the better answer : jans = 9, pans = 2 |
27 |
Halted |
0 ms |
0 KB |
- |