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;
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()
map<int, vector<int>> mp;
vector<int> solve(int n, int last) {
vector<int> v = { n - 1 };
for (int i = last; i * i <= n; i++) {
if (n % i == 0) {
auto q = solve(n / i, i);
for (int x : q) {
x += i - 1;
v.push_back(x);
}
}
}
sort(all(v));
v.erase(unique(all(v)), v.end());
return v;
}
signed main() {
#ifdef HOME
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
cin >> n;
auto v = solve(n, 2);
cout << v.size() << "\n";
for (int x : v)
cout << x << " ";
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... |