Submission #113324

#TimeUsernameProblemLanguageResultExecution timeMemory
113324maruiiToys (CEOI18_toy)C++14
100 / 100
618 ms24596 KiB
#include <bits/stdc++.h> using namespace std; vector<int> f(int x, int a) { vector<int> ret = {x - 1}; for (int i = a; i * i <= x; ++i) { if (x % i) continue; auto v = f(x / i, i); for (auto j: v) ret.push_back(j + i - 1); } return ret; } int main(){ ios_base::sync_with_stdio(0), cin.tie(0); int N; cin >> N; vector<int> ans = f(N, 2); sort(ans.begin(), ans.end()); ans.erase(unique(ans.begin(), ans.end()), ans.end()); cout << ans.size() << '\n'; for (auto 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...