Submission #1011287

#TimeUsernameProblemLanguageResultExecution timeMemory
1011287LucaLucaMToys (CEOI18_toy)C++17
100 / 100
1816 ms35508 KiB
#include <iostream> #include <vector> #include <algorithm> #include <cassert> #include <cstring> #include <map> #warning That's the baby, that's not my baby typedef long long ll; int n; std::map<int, std::vector<int>> divs; std::vector<int> answer; void bkt(int k, int v, int prod, int sum) { if (prod == n) { answer.push_back(sum); return; } std::vector<int> w = divs[n / prod]; for (const auto &val : w) { if (val >= v) { bkt(k + 1, val, prod * val, sum + val - 1); } } } int main() { std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cin >> n; std::vector<int> v; int d = 1; for (; d * d < n; d++) { if (n % d == 0) { v.push_back(d); v.push_back(n / d); } } if (d * d == n) { v.push_back(d); } std::sort(v.begin(), v.end()); v.erase(v.begin()); divs[n] = v; for (int i = 0; i < (int) v.size(); i++) { for (int j = i; j < (int) v.size(); j++) { if (v[j] % v[i] == 0) { divs[v[j]].push_back(v[i]); } } } bkt(0, 1, 1, 0); std::sort(answer.begin(), answer.end()); answer.erase(std::unique(answer.begin(), answer.end()), answer.end()); std::cout << (int) answer.size() << '\n'; for (const auto &val : answer) { std::cout << val << ' '; } return 0; }

Compilation message (stderr)

toy.cpp:7:2: warning: #warning That's the baby, that's not my baby [-Wcpp]
    7 | #warning That's the baby, that's not my baby
      |  ^~~~~~~
#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...