This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
// [CEOI2018] toys
#include <bits/stdc++.h>
using namespace std;
vector<int> F;
set<int> A;
void dfs(int li, const int s, const int n) {
if (n == 1) {
A.insert(s);
return;
}
for (size_t i = li; i < F.size() and F[i] <= n; ++i)
if (n % F[i] == 0) dfs(i, s + F[i] - 1, n / F[i]);
}
int main() {
ios::sync_with_stdio(false), cin.tie(0);
int n;
cin >> n;
for (int i = 2; i * i <= n; i++) {
if (n % i) continue;
F.push_back(i); // 计算所有约数
if (n % i != i) F.push_back(n / i);
}
F.push_back(n), sort(begin(F), end(F));
dfs(0, 0, n);
cout << A.size() << "\n";
for (int a : A) cout << a << " ";
return 0;
}
// ❓❓ 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... |