Submission #464949

#TimeUsernameProblemLanguageResultExecution timeMemory
464949idk321Toys (CEOI18_toy)C++17
79 / 100
5061 ms40208 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; map<int, set<int>> possibleAt; void solveFor(int num) { if (possibleAt.find(num) != possibleAt.end()) return; possibleAt[num].insert(num - 1); int cur = 2; while (cur * cur <= num) { if (num % cur == 0) { solveFor(cur); solveFor(num / cur); for (auto it = possibleAt[cur].begin(); it != possibleAt[cur].end(); it++) { for (auto it2 = possibleAt[num / cur].begin(); it2 != possibleAt[num / cur].end(); it2++) { possibleAt[num].insert(*it + *it2); } } } cur++; } } int main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; solveFor(n); cout << possibleAt[n].size() << "\n"; for (int i : possibleAt[n]) cout << i << " "; cout << "\n"; }
#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...