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;
map <int, vector <int>> mp;
vector <int> & calc(int x)
{
if (mp.find(x) != mp.end())
return mp[x];
vector <int> v = { x - 1 };
for (int i = 2; i * i <= x; i++) {
if (x % i == 0) {
auto& q = calc(x / i);
for (auto a : q)
v.push_back(a + i - 1);
}
}
sort(v.begin(), v.end());
v.resize(unique(v.begin(), v.end()) - v.begin());
mp[x] = v;
return mp[x];
}
int main()
{
//ifstream in("input.txt");
//ofstream out("output.txt");
int n;
cin >> n;
auto& x = calc(n);
cout << x.size() << '\n';
for (auto i : x)
cout << i << ' ';
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... |