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;
vector<int> f(int x, int a) {
vector<int> ret = {x - 1};
for (int i = a; i * i <= x; ++i) {
if (x % i) continue;
auto v = f(x / i, i);
for (auto j: v) ret.push_back(j + i - 1);
}
return ret;
}
int main(){
ios_base::sync_with_stdio(0), cin.tie(0);
int N; cin >> N;
vector<int> ans = f(N, 2);
sort(ans.begin(), ans.end());
ans.erase(unique(ans.begin(), ans.end()), ans.end());
cout << ans.size() << '\n';
for (auto i: ans) cout << i << ' ';
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... |