Submission #124473

#TimeUsernameProblemLanguageResultExecution timeMemory
124473RafikHachanaToys (CEOI18_toy)C++14
0 / 100
2 ms380 KiB
#include <bits/stdc++.h> using namespace std; unordered_set<int> s; //unordered_set<int> v; unordered_map<int,unordered_set<int> > m; unordered_map<int,int> val; unordered_set<int> dp(int n,int x) { if(n==1) { unordered_set<int> tmp; tmp.insert(x); return tmp; } unordered_set<int> tmp; if(val.find(n)!=val.end()) { for(auto it:m[n]) tmp.insert(it-val[n]+x); return tmp; } for(int i=1;i<=sqrt(n);i++) { if(n%i==0) { if(i!=1) { unordered_set<int> t1 = dp(n/i,x+i-1); for(auto it:t1) tmp.insert(it); } unordered_set<int> t2 = dp(i,x+n/i-1); for(auto it:t2) tmp.insert(it); } } val[n] = x; m[n] = tmp; return tmp; } int main() { int n; cin>>n; s = dp(n,0); cout<<s.size()<<endl; for(auto it:s) cout<<it<<" "; cout<<endl; }
#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...