Submission #728660

#TimeUsernameProblemLanguageResultExecution timeMemory
728660NeroZeinToys (CEOI18_toy)C++17
19 / 100
155 ms262144 KiB
#include "bits/stdc++.h" using namespace std; #ifdef Nero #include "Deb.h" #else #define deb(...) #endif const int N = 10005; bool dp[20][N][N]; int n; vector<int> ans; void bt (int sz, int s = 1, int sum = 0) { if (sz >= 20 || s >= N || sum >= N) { cout << "b"; exit(0); } bool& ret = dp[sz][s][sum]; if (ret) return; ret = true; if (sz == 0) { if (s == n) { ans.push_back(sum); return; } return; } for (int i = 1; i < n; ++i) { if (s * (i + 1) > n) break; bt(sz - 1, s * (i + 1), sum + i); } } signed main(){ ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n; for (int i = 0; (1 << i) <= n; ++i) { bt(i); } sort(ans.begin(), ans.end()); ans.resize(unique(ans.begin(), ans.end()) - ans.begin()); cout << (int) ans.size() << '\n'; for (int 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...