# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
233192 | luciocf | Toys (CEOI18_toy) | C++14 | 892 ms | 4560 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> d;
set<int> ans;
bool comp(int a, int b) {return a > b;}
void f(int ind, int prod, int soma)
{
if (ind >= d.size()) return;
if (prod == n)
{
ans.insert(soma);
return;
}
if (1ll*prod*d[ind] <= 1ll*n && (n%(prod*d[ind]) == 0))
f(ind, prod*d[ind], soma+d[ind]-1);
f(ind+1, prod, soma);
}
int main(void)
{
scanf("%d", &n);
for (int i = 2; i*i <= n; i++)
{
if (n%i) continue;
d.push_back(i);
if (n/i != i) d.push_back(n/i);
}
d.push_back(n);
sort(d.begin(), d.end(), comp);
f(0, 1, 0);
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... |