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 <vector>
#include <set>
#include <algorithm>
#define int int64_t
using namespace std;
vector<int> getdivs(int n)
{
vector<int> res;
for (int d = 2; d*d <= n; d++)
{
if (n % d == 0)
{
res.push_back(d);
if (d * d != n) res.push_back(n / d);
}
}
res.push_back(n);
sort(res.begin(), res.end());
return res;
}
signed main()
{
int n;
cin >> n;
vector<int> divs = getdivs(n);
int dc = divs.size();
vector<set<int>> res(dc);
for (int f = 0; f < dc; f++)
{
int fdiv = divs[f];
for (int sd = 0; sd < f; sd++)
{
int sdiv = divs[sd];
if (fdiv % sdiv == 0)
{
int od = fdiv / sdiv;
for (int nr : res[sd])
{
res[f].insert(nr + od - 1);
}
}
}
res[f].insert(fdiv - 1);
}
cout << res[dc - 1].size() << "\n";
for (int i : res[dc - 1]) cout << i << " ";
cout << "\n";
}
# | 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... |