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 <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define sc second
#define pb push_back
#define in insert
void dambo_12() {
int n , m; cin>>n>>m;
if (n % m == 0) {
cout<<n - 1<<'\n';
for (int i = 1; i < n; i++)
cout<<1<<' ';
cout<<'\n';
}
else if (m % n == 0){
cout<<m - 1<<'\n';
for (int i = 1; i < m; i++)
cout<<-1<<' ';
cout<<'\n';
}
else if (n > m){
int cnt = ((n + m - 1) / m) * m - 1;
cout<<cnt<<'\n';
for (int i = 1; i <= cnt; i++) {
if (i % m == 0) {
cout<<(m - 1) * 10000 + 1<<" ";
}
else {
cout<<-10000<<" ";
}
}
cout<<'\n';
}
else {
int cnt = ((m + n - 1) / n) * n - 1;
cout<<cnt<<'\n';
for (int i = 1; i <= cnt; i++) {
if (i % n == 0) {
cout<<(n - 1) * (-10000) - 1<<" ";
}
else {
cout<<10000<<" ";
}
}
cout<<'\n';
}
return;
}
int32_t main () {
ios::sync_with_stdio(false);
cin.tie(nullptr);
ll o = 1; cin>>o;
while (o--) {
dambo_12();
}
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... |