Submission #920803

#TimeUsernameProblemLanguageResultExecution timeMemory
920803UmairAhmadMirzaToys (CEOI18_toy)C++14
79 / 100
5025 ms4580 KiB
#include <bits/stdc++.h> using namespace std; // #define int long long set<int> ans; vector<int> divisor; void compute(int n,int min_d,int sm){ // if(sm<=ans.back()) // return; // cout<<n<<' '<<min_d<<' '<<sm<<endl; if(n==1){ ans.insert(sm); // cout<<"This is one of them : "; // cout<<sm<<endl; return; } // cout<<n<<' '<<max/d<<' '<<sm<<endl; // return; for(auto d:divisor){ if(d>n) break; if(n%d!=0 || d<min_d) continue; compute(n/d,d,sm+(d-1)); } } signed main(){ int n; cin>>n; divisor.push_back(n); for(int i=2;i*i<=n;i++){ if(n%i==0){ divisor.push_back(i); if((n/i)!=i) divisor.push_back(n/i); } } sort(divisor.begin(),divisor.end()); // for(auto i:divisor) // cout<<i<<endl; compute(n,1,0); cout<<ans.size()<<endl; for(auto i:ans) cout<<i<<' '; 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...