#include<bits/stdc++.h>
#define all(s) s.begin(),s.end()
using namespace std;
typedef int ll;
ll n,x,to[50];
vector<ll>v;
map<ll,bool>mp;
set<ll>s;
void best(ll d,ll mask,ll k,bool is,ll sum)
{
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(to[d],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();
to[n-1]=n;
for(ll i=n-2; i>=0; i--)
{
if(v[i]!=v[i+1])
to[i]=i+1;
else
to[i]=to[i+1];
// cout<<to[i]<<" ";
}
best(0,0,1,0,0);
cout<<s.size()<<endl;
for(auto z:s)
cout<<z<<" ";
return 0;
}
Compilation message
toy.cpp: In function 'void best(ll, ll, ll, bool, ll)':
toy.cpp:14:12: error: 'b' was not declared in this scope
14 | if(b[sum]==0)
| ^