제출 #1130181

#제출 시각아이디문제언어결과실행 시간메모리
1130181TsaganaNice sequence (IZhO18_sequence)C++20
100 / 100
302 ms42956 KiB
#include<bits/stdc++.h> #define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie(); #define all(x) x.begin(), x.end() #define int long long #define pq priority_queue #define eb emplace_back #define lb lower_bound #define ub upper_bound #define pb push_back #define pp pop_back #define F first #define S second using namespace std; int n, m; int T, k; int pre[400005]; void dfs(int s) { if (pre[s]) return; if (s - n >= 0) dfs(s - n); if (s + m <= k) dfs(s + m); pre[s] = T++; } void solve () { cin >> n >> m; k = n + m - __gcd(n, m) - 1; fill(pre, pre + k + 1, 0); T = 1; for (int i = 0; i <= k; i++) dfs(i); cout << k << endl; for (int i = 0; i < k; i++) cout << pre[i] - pre[i+1] << ' '; cout << '\n'; } signed main() {IOS int t; cin >> t; while (t--) solve(); 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...