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 pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
const int N = (int)2e5 + 5;
const int MAX = (int)1e9 + 5;
const ll mod = (int)1e9 + 7;
const ll inf = (int)(1e9) + 100;
int n;
map<int, vector<int>> dv;
vector<int> ans;
void rec(int c = 1, int sum = 0, int val = n) {
if (val == 1) {
ans.pb(sum);
return;
}
for (auto i : dv[val]) {
if (i < c) continue;
rec(i, sum + (i - 1), val / i);
}
}
void solve() {
cin >> n;
for (int i = 2; i * i <= n; i++) {
if (n % i == 0) {
dv[n].pb(i);
if (n / i != i) dv[n].pb(n / i);
}
}
dv[n].pb(n);
sort(all(dv[n]));
for (int i : dv[n]) {
for (int j = 2; j * j <= i; j++) {
if (i % j == 0) {
dv[i].pb(j);
if (i / j != j) dv[i].pb(i / j);
}
}
dv[i].pb(i);
sort(all(dv[i]));
}
rec();
sort(all(ans));
ans.erase(unique(all(ans)), ans.end());
cout << sz(ans) << "\n";
for (int i : ans) cout << i << " ";
}
signed main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int T = 1;
//cin >> T;
while (T--) solve();
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... |