# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
161354 | luciocf | Toys (CEOI18_toy) | C++14 | 1666 ms | 262148 KiB |
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;
int N;
vector<int> ans;
void solve(int n, int soma, int prod2)
{
if (n == 1)
{
if (prod2 == N) ans.push_back(soma);
return;
}
for (int i = 1; i*i <= n; i++)
{
if (n%i) continue;
int d = n/i;
solve(n/d, soma+d-1, prod2*d);
d = i;
if (i != 1 && i != n/i) solve(n/d, soma+d-1, prod2*d);
}
}
int main(void)
{
scanf("%d", &N);
solve(N, 0, 1);
sort(ans.begin(), ans.end()); ans.erase(unique(ans.begin(), ans.end()), ans.end());
printf("%d\n", ans.size());
for (auto x: ans)
printf("%d ", x);
printf("\n");
}
Compilation message (stderr)
# | 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... |