# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
986016 | raphaelp | Toys (CEOI18_toy) | C++14 | 5027 ms | 69516 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()
{
int N;
cin >> N;
if (N == 1)
{
cout << 1 << '\n'
<< 0;
return 0;
}
vector<int> div;
unordered_map<int, int> M;
for (int i = 2; i <= sqrt(N); i++)
{
if (N % i == 0)
{
div.push_back(i);
if (i != N / i)
div.push_back(N / i);
}
}
div.push_back(N);
sort(div.begin(), div.end());
for (int i = 0; i < div.size(); i++)
M[div[i]] = i;
vector<set<int>> pos(div.size());
for (int i = 0; i < div.size(); i++)
pos[i].insert(div[i] - 1);
for (int i = 0; i < div.size(); i++)
{
for (int j = 0; div[j] <= sqrt(div[i]); j++)
{
if (div[i] % div[j] != 0)
continue;
if ((N % (div[i] / div[j])) != 0)
continue;
int x = M[div[i] / div[j]];
for (auto k : pos[j])
{
for (auto l : pos[x])
{
pos[i].insert(k + l);
}
}
}
}
cout << pos[pos.size() - 1].size() << '\n';
for (auto i : pos[pos.size() - 1])
{
cout << i << ' ';
}
}
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... |