Submission #537353

#TimeUsernameProblemLanguageResultExecution timeMemory
537353Hydroxic_AcidToys (CEOI18_toy)C++17
59 / 100
5096 ms79196 KiB
#include <iostream> #include <algorithm> #include <vector> #include <cmath> #include <set> #include <map> using namespace std; int n; vector<int> v; set<int> ans; map<pair<int, pair<int, int> >, int > memo; void dp(int N, int i, int summ){ if(N == 1){ ans.insert(summ); return; } if(memo[make_pair(N, make_pair(i, summ))] == 1) return; for(int x = 0; x < (int)v.size(); x++){ if(v[x] >= i && N % v[x] == 0){ dp(N / v[x], v[x], summ + v[x] - 1); } } memo[make_pair(N, make_pair(i, summ))] = 1; } signed main(){ cin >> n; int f = 1; while(f <= (int)sqrt(n)){ if(n % f == 0){ if(f != 1) v.push_back(f); if(n/f != f) v.push_back(n/f); } f++; } dp(n, 0, 0); cout << (int)ans.size() << "\n"; for(set<int>::iterator it = ans.begin(); it != ans.end(); it++){ cout << (*it) << " "; } }
#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...