This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/*DavitMarg*/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <stack>
#include <cassert>
#include <iterator>
#include <bitset>
#include <fstream>
#define mod 1000000007ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v) v.begin(),v.end()
using namespace std;
int n;
vector<pair<LL,LL>> a;
set<LL> s;
void dfs(LL p,LL sum,LL d,LL cnt)
{
//cout<<sum<<" : "<<d<<endl;
if(p==a.size())
{
s.insert(sum+d-1);
return;
}
if(cnt==0)
cnt=a[p].second;
dfs(p+(cnt-1==0),sum+d-1,a[p].first,cnt-1);
dfs(p+(cnt-1==0),sum,d*a[p].first,cnt-1);
}
int main()
{
cin>>n;
for(LL i=2;i*i<=n;i++)
{
if(n%i)
continue;
a.PB(MP(i,0));
while(n%i==0)
{
a.back().second++;
n/=i;
}
}
if(n>1)
a.PB(MP(n,1));
sort(all(a));
do
{
dfs(0,0,1,0);
}while(next_permutation(all(a)));
cout<<s.size()<<endl;
for(auto it=s.begin();it!=s.end();++it)
printf("%lld ",(*it));
cout<<endl;
return 0;
}
/*
*/
Compilation message (stderr)
toy.cpp: In function 'void dfs(long long int, long long int, long long int, long long int)':
toy.cpp:32:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(p==a.size())
~^~~~~~~~~~
# | 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... |