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;
int n;
map <int, set <int>> memo;
set <int> rek(int x){
if(x == 1) return {};
if(memo[x].size() != 0) return memo[x];
set <int> ret = {x - 1};
for(int i = 2; i <= sqrt(x); i++){
set <int> s = rek(x / i);
for(auto e : s) ret.insert(e + i - 1);
}
memo[x] = ret;
return ret;
}
int main() {
cin >> n;
set <int> sol = rek(n);
if(sqrt(n) * sqrt(n) == n) sol.erase(sqrt(n) - 1);
cout << sol.size() << '\n';
for(int e : sol) cout << e << ' ';
return 0;
}
# | 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... |