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 <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
//ifstream cin ("date.in");
//ofstream cout ("date.out");
vector <int> sol,v;
set < pair<int,int> > s;
int x,nr,d;
void back (int x, int val){
if (s.find(make_pair(x,val)) != s.end()) /// ajung in aceeasi stare
return;
s.insert(make_pair(x,val));
sol.push_back(x+val-1);
/// vreau sa maresc nr de factori cu 1
for (int d=2;d<=x/d;d++)
if (x % d == 0)
back (x/d,val+d-1);
}
int main (){
cin>>x;
back (x,0);
sort (sol.begin(),sol.end());
sol.resize(unique(sol.begin(),sol.end())-sol.begin());
/*sort (v.begin(),v.end());
if (v.size())
sol.push_back(v[0]);
for (int i=1;i<v.size();i++)
if (v[i] != v[i-1])
sol.push_back(v[i]);*/
cout<<sol.size()<<"\n";
for (auto x:sol)
cout<<x<<" ";
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... |