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>> opt;
map<int, bool> d;
vector<int> dfs(int i)
{
if (d[i]) return opt[i];
d[i] = 1;
map<int, bool> m;
vector<int> nums;
nums.push_back(i-1);
m[i-1]= 1;
opt[i].push_back(i-1);
for (int j = 2; j*j <= i; j++)
{
if (i%j==0)
{
for (int ele:dfs(i/j))
{
if (!m[ele+j-1])
{
nums.push_back(ele+j-1);
opt[i].push_back(ele+j-1);
}
m[ele+j-1]=1;
}
}
}
return nums;
}
int main()
{
int n;
cin >> n;
vector<int> v(dfs(n));
sort(v.begin(), v.end());
cout << v.size()<< "\n";
for (int ele:v) cout << ele << " ";
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... |