Submission #400992

#TimeUsernameProblemLanguageResultExecution timeMemory
400992KoDToys (CEOI18_toy)C++17
100 / 100
2989 ms86668 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...