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
int n;
set<int>ans;
int nr, d;
vector<int>Div;
int st[40];
void backt (int prod, int k, int sum) {
ans.insert(sum + n / prod - 1);
if (prod == n)
return;
for (int i = st[k - 1]; i < d; i++) {
ll x = prod * Div[i];
if (n % x == 0) {
st[k] = i;
backt(x, k + 1, sum + Div[i] - 1);
}
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
cin >> n;
for (int i = 1; i * i <= n; i++) {
if (n % i == 0) {
if (i > 1)
Div.push_back(i);
if (i != n / i)
Div.push_back(n/i);
}
}
d = Div.size();
sort(Div.begin(), Div.end());
backt(1, 1, 0);
cout << ans.size() << "\n";
for (auto it : ans)
cout << it << " ";
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... |