제출 #91929

#제출 시각아이디문제언어결과실행 시간메모리
91929popovicirobertNice sequence (IZhO18_sequence)C++14
6 / 100
2 ms420 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...