Submission #920806

#TimeUsernameProblemLanguageResultExecution timeMemory
920806Faisal_SaqibToys (CEOI18_toy)C++17
100 / 100
3113 ms90324 KiB
#include <iostream> #include <map> #include <algorithm> #include <set> #include <vector> using namespace std; map<int,set<int>> mp; vector<int> dvv; void pos(int x) { auto it=mp.find(x); if(it!=mp.end()) return; mp[x]={}; it=mp.find(x); it->second.insert(x-1); // for(long long d=2;(d*d)<=x;d++) for(auto&d:dvv) { if(d>=x) { break; } if(x%d==0) { int rem=x/d; pos(rem); for(auto&j:mp[rem]) it->second.insert(j+(d-1)); if((d*d)!=x) { d=x/d; int rem=x/d; pos(rem); for(auto&j:mp[rem]) it->second.insert(j+(d-1)); d=x/d; } } } } int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(0); int n; cin>>n; for(int j=2;(j*j)<=n;j++) { if(n%j==0) { dvv.push_back(j); if((j*j)!=n) dvv.push_back(n/j); } } dvv.push_back(n); sort(begin(dvv),end(dvv)); pos(n); auto tlp=mp[n]; cout<<tlp.size()<<endl; for(auto j:tlp) { cout<<j<<' '; } cout<<endl; }
#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...