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)1e8 + 5;
const ll mod = (int)1e9 + 7;
const ll inf = (int)(1e9) + 100;
int n;
map<int, vector<int>> dv;
vector<int> ans;
bitset<MAX> b;
void rec(int c = 1, int sum = 0, int val = n) {
if (val == 1) {
if (b[sum] == 0) ans.pb(sum);
b[sum] = 1;
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();
cout << sz(ans) << "\n";
sort(all(ans));
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... |