This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |