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>
#include <map>
using namespace std;
#define sz(x) (int(x.size()))
using vi = vector<int>;
map< int, vector<int> > res;
void solve(int i)
{
// cerr << "solve " << i << '\n';
if(res.find(i) != res.end()) return;
vi ans(1, i-1);
for(int j = 2; j < i && (j*j*j <= i || j <= 50); j++)
{
if(i % j == 0)
{
int u = j;
int v = i/j;
solve(u);
solve(v);
for(int a: res[u])
{
for(int b: res[v])
{
ans.push_back(a+b);
}
}
}
}
sort(ans.begin(), ans.end());
ans.erase(unique(ans.begin(), ans.end()), ans.end());
res[i] = ans;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
solve(n);
vi ans = res[n];
cout << sz(ans) << '\n';
for(int r: ans) cout << r << ' ';
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... |