Submission #920798

#TimeUsernameProblemLanguageResultExecution timeMemory
920798UmairAhmadMirzaToys (CEOI18_toy)C++17
79 / 100
5043 ms4540 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...