# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|
400992 | | KoD | Toys (CEOI18_toy) | C++17 | | 2989 ms | 86668 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>
template <class T>
using Vec = std::vector<T>;
using ll = long long;
int main() {
int N;
std::cin >> N;
Vec<int> divs;
for (int i = 1; i * i <= N; ++i) {
if (N % i == 0) {
divs.push_back(i);
if (i * i != N) {
divs.push_back(N / i);
}
}
}
std::sort(divs.begin(), divs.end());
Vec<std::set<int>> ways(divs.size());
ways[0].insert(0);
for (int i = 1; i < (int) divs.size(); ++i) {
for (int j = 0; j < i; ++j) {
if (divs[i] % divs[j] == 0) {
const auto add = (divs[i] / divs[j]) - 1;
for (const auto x: ways[j]) {
ways[i].insert(x + add);
}
}
}
}
const auto& ans = ways.back();
std::cout << ans.size() << '\n';
bool first = true;
for (const auto x: ans) {
if (!first) std::cout << ' ';
first = false;
std::cout << x;
}
std::cout << '\n';
return 0;
}
# | 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... |