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,op;
bool b[100009],dp[18][1<<18];
set<ll>s;
void best(ll d,ll sum)
{
if(d==n)
{
if(b[sum]==0)
s.insert(sum),b[sum]=1;
return;
}
if(dp[d][sum])
return;
dp[d][sum]=1;
for(ll i=0; i<18; i++)
{
sum-=op[i]-1;
op[i]*=v[d];
sum+=op[i]-1;
best(d+1,sum);
sum-=op[i]-1;
op[i]/=v[d];
sum+=op[i]-1;
}
}
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();
//cout<<n<<endl;
for(ll i=0; i<18; i++)
op.push_back(1);
best(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... |