Submission #448642

#TimeUsernameProblemLanguageResultExecution timeMemory
448642CalicoToys (CEOI18_toy)C++17
59 / 100
5035 ms1504 KiB
#include <bits/extc++.h> using namespace std; set<int> ans; map<int, vector<int>> dvs; void brute(int n, int sum) { ans.insert(n+sum-1); for (int i: dvs[n]) { brute(n/i, sum+i-1); } } signed main() { ios::sync_with_stdio(0); cin.tie(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) { for (int i = 1; i*i <= j; i++) { if (j % i == 0) { int a = i, b = j/i; if (a != 1 && a != j) dvs[j].push_back(a); if (a != b && b != 1 && b != j) dvs[j].push_back(b); } } } brute(n, 0); cout << ans.size() << '\n'; for (int i: ans) 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...