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>
#define all(s) s.begin(),s.end()
using namespace std;
typedef int ll;
ll n;
vector<ll>v;
bool b[200009];
set<ll>s;
void best(ll d,ll mask,ll k,bool is,ll sum)
{
//cout<<d<<" "<<mask<<" "<<k<<" "<<is<<" "<<sum<<endl;
if(mask==(1<<n)-1)
{
sum+=k-1;
if(b[sum]==0)
b[sum]=1,s.insert(sum);
return;
}
if(d==n)
return void(best(0,mask,1,0,sum+k-1));
if((1<<d)&mask)
return void(best(d+1,mask,k,is,sum));
best(d+1,(1<<d)|mask,k*v[d],1,sum);
if(is)
best(d+1,mask,k,1,sum);
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n;
for(ll i=2; i*i<=n; i++)
{
while(n%i==0)
n/=i,v.push_back(i);
}
if(n>1)
v.push_back(n);
n=v.size();
best(0,0,1,0,0);
cout<<s.size()<<endl;
for(auto z:s)
cout<<z<<" ";
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... |