Submission #823500

#TimeUsernameProblemLanguageResultExecution timeMemory
823500NK_Toys (CEOI18_toy)C++17
100 / 100
672 ms79476 KiB
// Success consists of going from failure to failure without loss of enthusiasm #include <bits/stdc++.h> using namespace std; #define nl '\n' #define pb push_back #define sz(x) int(x.size()) template<class T> using V = vector<T>; using vi = V<int>; int main() { cin.tie(0)->sync_with_stdio(0); int N; cin >> N; if (N == 1) { cout << 1 << nl; cout << 0 << nl; return 0; } vi D; for(int i = 1; i * i <= N; i++) { if (N % i == 0) { D.pb(i); if (i*i != N) D.pb(N / i); } } int M = sz(D); sort(begin(D), end(D)); V<unordered_set<int>> ans(M); ans[0].insert(0); for(int i = 0; i < M; i++) { for(int j = 0; j < i; j++) { if (D[i] % D[j] == 0) for(auto& x : ans[j]) ans[i].insert(x + (D[i] / D[j]) - 1); } } vi ANS(begin(ans.back()), end(ans.back())); sort(begin(ANS), end(ANS)); cout << sz(ANS) << nl; for(auto& x : ANS) cout << x << " "; cout << nl; 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...