Submission #683769

#TimeUsernameProblemLanguageResultExecution timeMemory
683769MateGiorbelidzeNice sequence (IZhO18_sequence)C++14
15 / 100
10 ms724 KiB
#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 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...