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> dv;
set<int> ans;
void brute(int n, int sum) {
ans.insert(n+sum-1);
for (int i: dv) {
if (i >= n) break;
if (i == 1) continue;
if (n % i == 0) {
brute(n/i, sum+i-1);
}
}
}
signed main() {
ios::sync_with_stdio(0); cin.tie(0);
int n; cin >> n;
for (int i = 1; i*i <= n; i++) {
if (n % i == 0) {
int a = i, b = n/i;
dv.push_back(a);
if (a != b) dv.push_back(b);
}
}
sort(dv.begin(), dv.end());
brute(n, 0);
cout << ans.size() << '\n';
for (int 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... |