Submission #426346

#TimeUsernameProblemLanguageResultExecution timeMemory
426346lukadupliToys (CEOI18_toy)C++14
100 / 100
3509 ms90128 KiB
#include <bits/stdc++.h> using namespace std; int n; map <int, set <int>> memo; set <int> rek(int x){ if(x == 1) return {0}; if(memo[x].size() != 0) return memo[x]; set <int> ret = {x - 1}; for(int i = 2; i <= sqrt(x); i++){ if(x % i > 0) continue; set <int> s = rek(x / i); for(auto e : s) ret.insert(e + i - 1); } memo[x] = ret; return ret; } int main() { cin >> n; set <int> sol = rek(n); cout << sol.size() << '\n'; for(int e : sol) cout << e << ' '; 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...