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<iostream>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
vector<int> Q;
set<int> wynik;
set<int>::iterator it;
void rozklad(int n)
{
for(int i=1;i*i<=n;i++)
if(n%i==0)
{
if(i*i==n)
Q.push_back(i);
else{
Q.push_back(i);
Q.push_back(n/i);
}
}
sort(Q.begin(),Q.end());
}
void oblicz(int n,int gdzie,int suma)
{
if(n==1)
{
wynik.insert(suma);
return;
}
for(int i=gdzie;i>0;i--)
{
if(n%Q[i]==0)
oblicz(n/Q[i],i,suma+Q[i]-1);
}
}
int main()
{
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio(0);
int n;
cin>>n;
rozklad(n);
oblicz(n,Q.size()-1,0);
cout<<wynik.size()<<"\n";
for(it=wynik.begin();it!=wynik.end();it++)
cout<<*it<<" ";
return 0;
}
# | 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... |