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> ans;
void solve(int n, int sum = 0) {
if(n == 1) {
ans.push_back(sum);
return;
}
int x = sqrt(n);
for(int i = 2; i <= x; i++) {
if(n % i == 0) {
solve(n / i, sum + i - 1);
if(i != n / i) {
solve(n / (n / i), sum + (n / i) - 1);
}
}
}
solve(1, sum + n - 1);
}
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int N;
cin >> N;
solve(N);
sort(ans.begin(), ans.end());
ans.resize(unique(ans.begin(), ans.end()) - ans.begin());
cout << ans.size() << '\n';
for(auto v : ans) {
cout << v << ' ';
}
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... |