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 <bits/stdc++.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
#include <stack>
#include <string>
#include <map>
#include <queue>
using namespace std;
const long long oo = 1000000000000000000;
long long int sum, ans = 0, mx = 0, mn = 1000000000, num, pos;
/*
ViHHiPuh
(( `'-""``""-'` ))
)-__-_.._-__-(
/ --- (o _ o) --- \
\ .-* ( .0. ) *-. /
_'-. ,_ '=' _, .-'_
/ `;#'#'# - #'#'#;` \
\_)) -----'#'----- ((_/
# --------- #
'# ------- ------ #'
/..-'# ------- #'-.\
_\...-\'# -- #'/-.../_
((____)- '#' -(____))
cout << fixed << setprecision(6) << x;
freopen ( "sum.in", "r", stdin )
*/
vector <int> v;
int a[ 200001 ], n, m;
int main () {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int t;
cin >> t;
while ( t -- ) {
cin >> n >> m;
mn = min( n, m );
mx = max( n, m );
if ( n % m == 0 || m % n == 0 ) {
if ( n > m ) {
cout << n - 1 << "\n";
for ( int i = 1; i < n; i ++ )
cout << 1 << " ";
}
else {
cout << m - 1 << "\n";
for ( int i = 1; i < m; i ++ )
cout << -1 << " ";
}
cout << "\n";
}
else if ( min( n, m ) == 2 ) {
cout << max( n, m ) << "\n";
mx = max( n, m );
if ( n == 2 ) {
for ( int i = 1; i <= mx; i ++ ) {
if ( i % 2 )
cout << mx << " ";
else
cout << ( mx * -1 ) - 1 << " ";
}
cout << "\n";
}
else {
for ( int i = 1; i <= mx; i ++ ) {
if ( i % 2 == 0 )
cout << mx + 1 << " ";
else
cout << ( mx * -1 ) << " ";
}
cout << "\n";
}
}
else {
cout << mx + 1 << "\n";
}
}
}
/*
3 4
3 5 -9 2
2 2 -5 2 2
3 5
-3 5 -3 -3 5 -3
0 0 0 0 0 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... |