# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
161349 | luciocf | Toys (CEOI18_toy) | C++14 | 5037 ms | 1080 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 main(void)
{
int n;
scanf("%d", &n);
if (n == 1)
{
printf("1\n0\n");
return 0;
}
vector<int> p;
int aux = n;
for (int i = 2; i*i <= aux; i++)
{
while (aux%i == 0)
{
aux /= i;
p.push_back(i);
}
}
if (aux > 1) p.push_back(aux);
set<int> ans;
do
{
for (int mask = 0; mask < (1<<((int)p.size()-1)); mask++)
{
if (ans.size() >= 27000)
{
printf("%d\n", ans.size());
for (auto x: ans)
printf("%d ", x);
printf("\n");
return 0;
}
int soma = 0;
int prod = 1, prod2 = 1;
for (int i = 0; i < ((int)p.size()-1); i++)
{
prod *= p[i];
if (mask&(1<<i))
{
soma += (prod-1);
prod2 *= prod;
prod = 1;
}
}
prod *= p.back();
soma += (prod-1);
prod2 *= prod;
if (prod2 == n)
ans.insert(soma);
}
} while (next_permutation(p.begin(), p.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... |