Submission #536850

#TimeUsernameProblemLanguageResultExecution timeMemory
536850ecxToys (CEOI18_toy)C++17
79 / 100
5058 ms61316 KiB
#include <bits/stdc++.h> using namespace std; set<pair<int, int>> vs; set<int> s; void dp(int n, int built) { if (vs.find({n, built}) != vs.end()) return; vs.insert({n, built}); s.insert(n+built-1); for (int i = 2; i*i<=n; i++) { if (n%i==0) { dp(n/i, built+i-1); } } } int main() { int n; cin >> n; dp(n, 0); cout << s.size() << endl; for (int k : s) cout << k << " "; cout << endl; }
#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...