# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
828460 | shoryu386 | Toys (CEOI18_toy) | C++17 | 2501 ms | 93804 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>
using namespace std;
#define int long long
map<int, set<int>> deepee;
set<int> recur(int n){
if (n == 1) return {1};
if (deepee.count(n) != 0) return deepee[n];
set<int> ret;
for (int x = 1; x <= sqrt(n); x++){
if (n % x == 0) {
//cerr << "wat " << n/x << ' ' << x << '\n';
if (n/x != n){
for (auto y : recur(n/x)){
ret.insert(x - 1 + y);
}
}
for (auto y : recur(x)){
ret.insert(n/x -1 + y);
}
}
}
return deepee[n] = ret;
}
main(){
int n; cin >> n;
set<int> ans = recur(n);
cout << ans.size() << '\n';
for (auto x : ans){
cout << x-1 << ' ';
}
}
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... |