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;
int valori[1000005],q1,n,q,divi[1000005],solutii[1000005],fin;
map <int,int> m;
void back1(int nr,int suma,int prod)
{
if (prod==n)
{
m[suma-nr]=1;
return;
}
int i;
for (i=1;i<=q;i++)
{
if ((n/prod)%divi[i]==0&&solutii[nr-1]<=divi[i])
{
solutii[nr]=divi[i];
back1(nr+1,suma+divi[i],prod*divi[i]);
}
}
}
int i;
int main()
{
#ifdef HOME
ifstream cin("date.in");
ofstream cout("date.out");
#endif // HOME
cin>>n;
if (n==1)
{
cout<<"1"<<'\n';
cout<<"0";
return 0;
}
for (i=1;i*i<=n;i++)
{
if (n%i==0)
{
if (i!=1)
{
divi[++q]=i;
}
divi[++q]=n/i;
}
}
back1(0,0,1);
for (auto ind:m)
{
solutii[++fin]=ind.first;
}
cout<<fin<<'\n';
for (i=1;i<=fin;i++)
{
cout<<solutii[i]<<" ";
}
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... |