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 <iostream>
#include <algorithm>
using namespace std;
int n, ans[10000001], size, sum;
void DFS(int n, int p)
{
//cout << "DFS " << n << " " << p << "\n";
if (n == 1)
{
ans[size++] = sum;
}
else
{
for (int i = 1; i * i <= n; i++)
{
if (n % i == 0)
{
if (i <= p && i > 1)
{
sum += i - 1;
DFS(n / i, i);
sum -= i - 1;
}
if (n / i <= p)
{
sum += n / i - 1;
DFS(i, n / i);
sum -= n / i - 1;
}
}
}
}
}
int main()
{
ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n;
DFS(n, 1000000000);
sort(ans, ans + size);
size = unique(ans, ans + size) - ans;
cout << size << "\n";
for (int i = 0; i < size; i++)
{
cout << ans[i];
if (i + 1 < size) cout << " ";
}
cout << "\n";
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... |