Submission #584975

#TimeUsernameProblemLanguageResultExecution timeMemory
584975JomnoiToys (CEOI18_toy)C++17
59 / 100
978 ms262144 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); return; } int x = sqrt(n); for(int i = 2; i <= x; i++) { if(n % i == 0) { solve(n / i, sum + i - 1); if(i != n / i) { solve(n / (n / i), sum + (n / i) - 1); } } } solve(1, sum + n - 1); } int main() { cin.tie(nullptr)->sync_with_stdio(false); int N; cin >> N; solve(N); 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...