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>
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define f first
#define s second
using namespace std;
using ll = long long;
using pii = pair <int, int>;
const int N = 2e5 + 5;
int n;
vector <int> p;
set <ll> st;
void solve(int x, int i, ll sum) {
if (x == 1) {
st.insert(sum);
return;
}
while (i >= 0 && x % p[i])
i--;
if (i < 0)
return;
solve(x, i - 1, sum);
solve(x / p[i], i, sum + p[i] - 1);
}
int main() {
ios :: sync_with_stdio(0);
cin.tie(0);
cin >> n;
for (int i = 2; i * i <= n; ++i) {
if (n % i == 0) {
p.pb(i);
if (i * i != n)
p.pb(n / i);
}
}
p.pb(n);
sort(all(p));
solve(n, sz(p) - 1, 0);
cout << sz(st) << '\n';
for (auto x : st)
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... |