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> dp(int n, int mini) {
vector<int> ans = {n - 1};
if(n == 1) {
return ans;
}
for(int i = mini; i * i <= n; ++i) {
if(n % i == 0) {
for(int x : dp(n / i, i)) {
ans.push_back(x + i - 1);
}
}
}
return ans;
}
int main() {
ios::sync_with_stdio(0); cin.tie(0);
int n;
cin >> n;
vector<int> ans = dp(n, 2);
set<int> s(ans.begin(), ans.end());
cout << (int)s.size() << '\n';
for(int i : s) cout << i << ' ';
}
# | 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... |