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 int long long
#define ii pair<int,int>
#define F first
#define S second
#define du long double
using namespace std;
map<int,vector<int>> vec;
map<ii,bool>mp;
set<int> st;
vector<int> p;
int sz;
void fix(int u,int i,int sum,int v)
{
if(i==sz){
if(sum!=1)vec[v].push_back(sum);
return;
}
fix(u,i+1,sum,v);
if(u%p[i]==0)fix(u/p[i],i,sum*p[i],v);
}
void bc(int n,int sum)
{
// if(mp[{n,sum}])return;
// mp[{n,sum}]=1;
if(n==1){
st.insert(sum);
return;
}
if(vec.count(n)==0){
vec[n].push_back(n);
fix(n,0,1,n);
}
for(auto x:vec[n]){
bc(n/x,sum+x-1);
}
}
bool ok(int u)
{
for(int i=2;i*i<=u;i++)
if(u%i==0)return 0;
return 1;
}
void solve()
{
int n;
cin>>n;
for(int i=2;i*i<=n;i++){
if(ok(i)){
p.push_back(i);
sz++;
}
}
bc(n,0);
cout<<st.size()<<endl;
for(auto x:st)printf("%d ",x);
}
main()
{
int t=1;
//cin>>t;
while(t--)solve();
}
Compilation message (stderr)
toy.cpp:58:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
58 | main()
| ^~~~
# | 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... |