Submission #448163

#TimeUsernameProblemLanguageResultExecution timeMemory
448163CalicoToys (CEOI18_toy)C++17
100 / 100
967 ms4972 KiB
#include <bits/extc++.h> using namespace std; unordered_set<int> ans; unordered_map<int, vector<int>> dvs; void brute(int n, int sum, int prv) { ans.insert(n+sum-1); for (int i: dvs[n]) { if (i < prv) break; brute(n/i, sum+i-1, i); } } signed main() { ios::sync_with_stdio(0); cin.tie(0); signal(SIGFPE, [](int) { _Exit(0); }); int n; cin >> n; vector<int> dv; for (int i = 1; i*i <= n; i++) { if (n % i == 0) { int a = i, b = n/i; dv.push_back(a); if (a != b) dv.push_back(b); } } for (int j: dv) { int lm = 0; for (int i = 1; i*i <= j; i++) { lm = i; if (j % i == 0) { int a = i, b = j/i; if (a != b && b != 1 && b != j) dvs[j].push_back(b); } } for (int i = lm; i >= 1; i--) { if (j % i == 0) { int a = i; if (a != 1 && a != j) dvs[j].push_back(a); } } } brute(n, 0, 1); vector<int> anss(ans.begin(), ans.end()); sort(anss.begin(), anss.end()); cout << anss.size() << '\n'; for (int i: anss) cout << i << ' '; 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...