Submission #1051615

#TimeUsernameProblemLanguageResultExecution timeMemory
1051615antonToys (CEOI18_toy)C++17
59 / 100
5063 ms7360 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<pii, bool> vis; unordered_set<int> possib; void get_sums(int n, int d){ if(n==1){ possib.insert(d); return; } vis[pii(n, d)] = true; auto factors = factorize(n); for(auto e: factors){ get_sums(n/e, d+e-1); } } signed main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cin>>N; get_sums(N, 0); vector<int> res; for(auto e: possib){ res.push_back(e); } 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...