Submission #584971

#TimeUsernameProblemLanguageResultExecution timeMemory
584971JomnoiToys (CEOI18_toy)C++17
59 / 100
5009 ms66000 KiB
#include <bits/stdc++.h> using namespace std; vector <int> ans; void solve(int n, int sum = 0) { if(n == 1) { ans.push_back(sum); } for(int i = 2; i <= n; i++) { if(n % i == 0) { solve(n / i, sum + i - 1); } } } int main() { cin.tie(nullptr)->sync_with_stdio(false); int N; cin >> N; solve(N); ans.push_back(N - 1); sort(ans.begin(), ans.end()); ans.resize(unique(ans.begin(), ans.end()) - ans.begin()); cout << ans.size() << '\n'; for(auto v : ans) { cout << v << ' '; } 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...