This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <climits>
#include <cmath>
#include <fstream>
#include <queue>
#include <stack>
#include <bitset>
using namespace std;
#define ll long long
//cin.tie(0);ios_base::sync_with_stdio(0);
void solve() {
int n, m;
cin >> n >> m;
int sign = 1;
if (m > n) {
sign = -1;
}
if (n < m) {
swap(n, m);
}
if (n == m) {
cout << n - 1 << endl;
if (n - 1 != 0) {
for (int i = 0; i < n - 1; i++) {
cout << 1 << " ";
}
cout << endl;
}
return;
}
if (n % m == 0) {
cout << n - 1 << endl;
for (int i = 0; i < n - 1; i++) {
cout << 1 * sign << " ";
}
cout << endl;
return;
}
else {
cout << n << endl;
for (int i = 0; i < n; i++) {
if (i % 2 == 0) {
cout << 3 * sign * -1 << " ";
}
else {
cout << 4 * sign << " ";
}
}
cout << endl;
return;
}
}
int main(){
int t;
cin >> t;
while (t--) {
solve();
}
}
# | 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... |