# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
114789 | Meloric | Toys (CEOI18_toy) | C++14 | 1313 ms | 83456 KiB |
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 <bits/stdc++.h>
#define int int64_t
#define pb push_back
#define X first
#define Y second
#define pii pair<int, int>
using namespace std;
unordered_map<int, unordered_set<int>> mem;
vector<int> divs(int n){
vector<int> ans;
for(int i = 1; i*i<=n; i++){
if(n%i == 0){
ans.pb(i);
ans.pb(n/i);
}
}
return ans;
}
void dp(int n){
if(mem.find(n)!= mem.end())return;
vector<int> dv;
dv = divs(n);
unordered_set<int> ans;
for(int i = 1; i< dv.size(); i++){
int tmp = n/dv[i];
dp(tmp);
for(int j : mem.find(tmp)->Y){
ans.insert(j+dv[i]-1);
}
}
mem.insert({n, ans});
}
signed main(){
int n; cin >> n;
mem.insert({1, {0}});
dp(n);
vector<int> ans;
for(int j : mem.find(n)->Y){
ans.pb(j);
}
sort(ans.begin(), ans.end());
cout << ans.size()<<'\n';
for(int j : ans){
cout << j << ' ';
}
}
Compilation message (stderr)
# | 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... |