Submission #393232

#TimeUsernameProblemLanguageResultExecution timeMemory
393232nikatamlianiToys (CEOI18_toy)C++14
100 / 100
888 ms24212 KiB
#include <bits/stdc++.h> using namespace std; vector<int> dp(int n, int mini) { vector<int> ans = {n - 1}; if(n == 1) { return ans; } for(int i = mini; i * i <= n; ++i) { if(n % i == 0) { for(int x : dp(n / i, i)) { ans.push_back(x + i - 1); } } } return ans; } int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<int> ans = dp(n, 2); set<int> s(ans.begin(), ans.end()); cout << (int)s.size() << '\n'; for(int i : s) cout << i << ' '; }
#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...