Submission #1051668

#TimeUsernameProblemLanguageResultExecution timeMemory
1051668antonToys (CEOI18_toy)C++17
100 / 100
1769 ms72988 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define pii pair<int, int> int N; vector<int> factorize(int n){ vector<int> res; for(int i = 2; i*i<=n;i++){ if(n%i == 0){ res.push_back(i); if(i*i!=n){ res.push_back(n/i); } } } res.push_back(n); return res; } map<int, unordered_set<int>> m; vector<int> res; void get_sums(int n){ auto ds = m[n]; if(n==1){ for(auto e: ds){ res.push_back(e); } return; } auto factors = factorize(n); for(auto e: factors){ for(auto ee: ds){ m[n/e].insert(ee+e-1); } } } signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cin>>N; m[N].insert(0); while(m.size()>0){ get_sums((--m.end())->first); m.erase(--m.end()); } sort(res.begin(), res.end()); cout<<res.size()<<endl; for(auto e: res){ cout<<e<<" "; } 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...