Submission #153735

#TimeUsernameProblemLanguageResultExecution timeMemory
153735nicolaalexandraToys (CEOI18_toy)C++14
79 / 100
1209 ms20548 KiB
#include <iostream> #include <vector> #include <algorithm> #include <set> using namespace std; //ifstream cin ("date.in"); //ofstream cout ("date.out"); vector <int> sol; set < pair<int,int> > s; int x,nr,k,d,v[1000]; 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=1;d<=k&&v[d]<=x/v[d];d++) if (x % v[d] == 0) back (x/v[d],val+v[d]-1); } 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); 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...