# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
493217 | 2021-12-10T12:27:55 Z | blue | Toys (CEOI18_toy) | C++17 | 0 ms | 0 KB |
#include <iostream> #include <vector> #include <set> using namespace std; #define sz(x) (int(x.size())) int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; vector<int> res[1+n]; for(int i = 1; i <= n; i++) { res[i].push_back(i-1); for(int j = 1; j < i; j++) { if(i % j == 0) { int u = j; int v = i/j; for(int a: res[u]) for(int b: res[v]) res[i].push_back(a+b); // break; } } sort(res[i].begin(), res[i].end()); res[i].erase(unique(res[i].begin(), res[i].end()), res[i].end()); } cout << sz(res[n]) << '\n'; for(int r: res[n]) cout << r << ' '; cout << '\n'; }