Submission #117190

#TimeUsernameProblemLanguageResultExecution timeMemory
117190teomrnToys (CEOI18_toy)C++14
100 / 100
1062 ms22332 KiB
#include <bits/stdc++.h> using namespace std; map <int, vector <int>> mp; vector <int> & calc(int x) { if (mp.find(x) != mp.end()) return mp[x]; vector <int> v = { x - 1 }; for (int i = 2; i * i <= x; i++) { if (x % i == 0) { auto& q = calc(x / i); for (auto a : q) v.push_back(a + i - 1); } } sort(v.begin(), v.end()); v.resize(unique(v.begin(), v.end()) - v.begin()); mp[x] = v; return mp[x]; } int main() { //ifstream in("input.txt"); //ofstream out("output.txt"); int n; cin >> n; auto& x = calc(n); cout << x.size() << '\n'; for (auto i : x) cout << i << ' '; cout << '\n'; 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...