#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;
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;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |