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;
vector <int> sol;
set < pair<int,int> > s;
int x,nr,k,d,v[1000000];
void back (int x, int val, int start){
//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=start;d<=x/d;d++)
if (x % d == 0)
back (x/d,val+d-1,d);
}
int main (){
cin>>x;
for (d=2;d<=x/d;d++){
if (x % d == 0){
v[++k] = d;
if (d != x/d)
v[++k] = x/d;
}}
v[++k] = x;
sort (v+1,v+k+1);
back (x,0,2);
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... |