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 <iostream>
#include <vector>
#include <random>
#include <algorithm>
#include <cassert>
#include <cstring>
using namespace std;
#define int long long
vector<int> ans;
void rec(int x, int mx, int c) {
if (x == 1) {
ans.push_back(c);
return;
}
int j = 1;
while (j * j <= x) {
if (x % j == 0) {
if (mx >= j && j != 1) {
rec(x / j, j, c + j - 1);
}
if (mx >= x / j) {
rec(j, j, c + x / j - 1);
}
}
++j;
}
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
rec(n, n + 1, 0);
sort(ans.begin(), ans.end());
ans.resize(unique(ans.begin(), ans.end()) - ans.begin());
cout << ans.size() << '\n';
for (int i : ans) 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... |