Submission #124384

#TimeUsernameProblemLanguageResultExecution timeMemory
124384RafikHachanaToys (CEOI18_toy)C++14
79 / 100
5092 ms37880 KiB
#include <bits/stdc++.h> using namespace std; set<int> s; set<pair<int,int> > v; void dp(int n,int x) { if(n==1) { s.insert(x); return; } if(v.find({n,x})!=v.end()) return; for(int i=1;i<=sqrt(n);i++) { if(n%i==0) { if(i!=1) dp(n/i,x+i-1); dp(i,x+n/i-1); //v.insert() } } v.insert({n,x}); } int main() { int n; cin>>n; 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...