제출 #1132641

#제출 시각아이디문제언어결과실행 시간메모리
1132641Halym2007Nice sequence (IZhO18_sequence)C++17
15 / 100
4 ms836 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define sz size() #define ff first #define ss second #define pb push_back #define pii pair <int, int> #define dur exit(0) #define dur1 return(0) const int N = 2e5 + 5; int jog[N]; int main () { // freopen ("input.txt", "r", stdin); ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); int t; cin >> t; while ( t-- ) { int n, m; cin >> n >> m; if (n % m == 0 or m % n == 0) { int x = (n > m ? 1 : -1); cout << max (n, m) - 1 << "\n"; for (int i = 1; i <= max (n, m) - 1; ++i) { cout << x << " "; } cout << "\n"; } else { if (n == 2) { int x = m / 2 + 1; for (int i = 1; i <= m; i += 2) { jog[i] = x; } for (int i = 2; i <= m; i +=2) { jog[i] = (x + 1) * (-1); } cout << m << "\n"; for (int i = 1; i <= m; ++i) { cout << jog[i] << " "; } cout << "\n"; } else if (m == 2) { int x = n / 2 + 1; for (int i = 1; i <= n; i += 2) { jog[i] = -x; } for (int i = 2; i <= n; i +=2) { jog[i] = x + 1; } cout << n << "\n"; for (int i = 1; i <= n; ++i) { cout << jog[i] << " "; } cout << "\n"; } } } }
#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...