Submission #485537

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