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 pb push_back
int n;
set<int> ans;
vector<int> all;
void backtrack(int idx, int num, int sum) {
int cur = all[idx];
if(cur == 1) {
if(num == 1) {
ans.insert(sum);
}
return;
}
backtrack(idx - 1, num, sum);
while(num % cur == 0) {
num /= cur;
sum += cur - 1;
backtrack(idx - 1, num, sum);
}
}
void solve() {
cin >> n;
for(int i = 1; i * i <= n; i++) {
if(n % i == 0) {
all.pb(i);
if(i * i != n) {
all.pb(n / i);
}
}
}
sort(all.begin(), all.end());
backtrack(all.size() - 1, n, 0);
cout << ans.size() << "\n";
for(int cur : ans) {
cout << cur << " ";
}
cout << "\n";
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
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... |