Submission #584985

#TimeUsernameProblemLanguageResultExecution timeMemory
584985JomnoiToys (CEOI18_toy)C++17
100 / 100
3196 ms90132 KiB
#include <bits/stdc++.h> using namespace std; set <int> ans; map <int, set <int>> dp; set <int> solve(int n) { if(dp.count(n)) { return dp[n]; } int x = sqrt(n); for(int i = 1; i <= x; i++) { if(n % i == 0) { solve(i); for(auto v : dp[i]) { dp[n].insert(v + n / i - 1); } if(i != 1) { solve(n / i); for(auto v : dp[n / i]) { dp[n].insert(v + i - 1); } } } } return dp[n]; } int main() { cin.tie(nullptr)->sync_with_stdio(false); int N; cin >> N; dp[1].insert(0); set <int> ans = solve(N); 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...