이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
#define ld long double
// 217
// 44
using namespace std;
const int INF = 999999999;
const int MAXN = (int) 2e5;
int arr[2 * MAXN + 1];
int main() {
//ifstream cin("A.in");
//ofstream cout("A.out");
int t, i;
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
cin >> t;
while(t > 0) {
t--;
int n, m;
cin >> n >> m;
int mn = min(n, m), mx = max(n, m);
if(mx % mn == 0) {
cout << mx - 1 << "\n";
int sign = 1;
if(mn == n) {
sign = -1;
}
for(i = 1; i < mx; i++) {
cout << sign << " ";
}
cout << "\n";
continue;
}
int sz = n + m - 2, val = INF / (n - 1);
int pos = 1;
cout << sz << "\n";
while(pos <= sz) {
for(i = 1; i <= n - 1 && pos <= sz; i++) {
arr[pos] = val;
pos++;
}
if(pos <= sz) {
arr[pos] = - val * (n - 1) - 1;
pos++;
}
}
int sign = 1;
if(n != mn) {
sign = -1;
}
for(i = 1; i <= sz; i++) {
cout << sign * arr[i] << " ";
}
cout << "\n";
}
//cin.close();
//cout.close();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |