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;
void pecah(int n, int prev, int nilai, set<int> &sett)
{
vector<int> factors;
for (int i = 2; i * i <= n; i++)
{
if (n % i == 0)
factors.push_back(i);
}
for (auto factor : factors)
{
int a = factor, b = n / factor;
if (a > b)
break;
sett.insert(nilai + a + b - 2);
pecah(b, a, nilai + a - 1, sett);
}
}
int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin >> n;
set<int> sett;
pecah(n, INF, 0, sett);
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... |