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 int long long
#define INF LLONG_MAX
#define pii pair<int, int>
using namespace std;
set<int> sett;
void pecah(int n, int prev, int nilai)
{
if (prev == INF)
prev = 2;
for (int i = prev; i * i <= n; i++)
{
if (n % i == 0)
{
int a = i, b = n / i;
if (a > b)
break;
sett.insert(nilai + a + b - 2);
pecah(b, a, nilai + a - 1);
}
}
}
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin >> n;
pecah(n, INF, 0);
cout << sett.size() + 1 << endl;
for (auto s : sett)
cout << s << " ";
cout << n - 1 << endl;
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... |