Submission #493225

#TimeUsernameProblemLanguageResultExecution timeMemory
493225blueToys (CEOI18_toy)C++17
19 / 100
1 ms332 KiB
#include <iostream> #include <vector> #include <set> #include <algorithm> #include <map> using namespace std; #define sz(x) (int(x.size())) using vi = vector<int>; map< int, vector<int> > res; void solve(int i) { // cerr << "solve " << i << '\n'; if(res.find(i) != res.end()) return; vi ans(1, i-1); for(int j = 2; j < i && (j*j*j <= i || j <= 50); j++) { if(i % j == 0) { int u = j; int v = i/j; solve(u); solve(v); for(int a: res[u]) { for(int b: res[v]) { ans.push_back(a+b); } } } } sort(ans.begin(), ans.end()); ans.erase(unique(ans.begin(), ans.end()), ans.end()); res[i] = ans; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin >> n; solve(n); vi ans = res[n]; cout << sz(ans) << '\n'; for(int r: ans) cout << r << ' '; cout << '\n'; }
#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...