Submission #485539

#TimeUsernameProblemLanguageResultExecution timeMemory
485539SirCovidThe19thNice sequence (IZhO18_sequence)C++17
100 / 100
412 ms41332 KiB
#include <bits/stdc++.h> using namespace std; int n, m, ti = 0, sz, pre[400005]; void dfs(int cur){ if (pre[cur]) return; if (cur - n >= 0) dfs(cur - n); if (cur + m <= sz) dfs(cur + m); pre[cur] = ++ti; } int main(){ int tc; cin >> tc; while (tc--){ cin >> n >> m; sz = n + m - __gcd(n, m) - 1; ti = 0; fill(pre, pre + sz + 1, 0); for (int i = 0; i <= sz; i++) dfs(i); cout<<sz<<endl; for (int i = 0; i < sz; i++) cout<<pre[i] - pre[i + 1]<<" "; cout<<endl; } }
#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...