Submission #536986

#TimeUsernameProblemLanguageResultExecution timeMemory
536986Hydroxic_AcidToys (CEOI18_toy)C++17
39 / 100
5070 ms360 KiB
#include <iostream> #include <algorithm> #include <vector> #include <cmath> #include <set> #include <map> using namespace std; #define int long long int n; vector<int> v; vector<int> ans; map<int, int> m; int temp[100000]; void dp(int idx, int curr, int fake, int end){ if(idx == (int)v.size()){ if(!m[curr - end - 1]){ ans.push_back(curr - end - 1); m[curr - end - 1] = 1; } return; } //if(memo[make_pair(idx, make_pair(curr, end))] == 1) return; temp[end + 1] = v[idx]; dp(idx + 1, curr + v[idx], end + 1, end + 1); temp[end + 1] = 0; if(idx != (int)v.size() - 1 && v[idx] == v[idx + 1]){ for(int i = end; i >= 0; i--){ temp[i] *= v[idx]; dp(idx + 1, curr + temp[i] - temp[i] / v[idx], i, end); temp[i] /= v[idx]; } return; } for(int i = end; i >= 0; i--){ temp[i] *= v[idx]; dp(idx + 1, curr + temp[i] - temp[i] / v[idx], end, end); temp[i] /= v[idx]; } //memo[make_pair(idx, make_pair(curr, end))] = 1; } signed main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; int f = 2; while(f <= (int)sqrt(n) + 1 && n > 1){ if(n % f == 0){ v.push_back(f); n = n/f; } else f++; } if(n > 1) v.push_back(n); dp(0, 0, -1, -1); cout << (int)ans.size() << "\n"; sort(ans.begin(), ans.end()); for(int i = 0; i < (int)ans.size(); i++){ cout << ans[i] << " "; } }
#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...