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>
using namespace std;
int n;
int ma;
set<int> s;
void f(int r,int p,int sum)
{
if(r==0)
{
if(n%p==0)
{
int x = n/p -1;
//cout<<x<<endl;
if(x>0)
{
s.insert(sum+x);
}
}
return;
}
for(int i=ma+5;i>0;i--)
{
//v.push_back(i);
f(r-1,p*(i+1),sum+i);
//v.pop_back();
}
}
int main()
{
cin>>n;
s.insert(n-1);
int r = 2;
while(true)
{
ma= ceil(pow(n,1.0/r));
//cout<<ma<<endl;
//cout<<456<<endl;
//vector<int> w;
f(r-1,1,0);
//f(r,w);
if(ma<=2) break;
r++;
}
cout<<s.size()<<endl;
for(auto it:s) cout<<it<<" ";
cout<<endl;
}
# | 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... |