Submission #536959

#TimeUsernameProblemLanguageResultExecution timeMemory
536959Hydroxic_AcidToys (CEOI18_toy)C++17
39 / 100
5060 ms340 KiB
#include <iostream> #include <algorithm> #include <vector> #include <cmath> #include <set> using namespace std; #define int long long int n; vector<int> v; set<int> ans; int temp[100000]; void dp(int idx, int curr, int end){ if(idx == (int)v.size()){ ans.insert(curr - end - 1); return; } temp[end + 1] = v[idx]; dp(idx + 1, curr + v[idx], end + 1); temp[end + 1] = 0; for(int i = end; i >= 0; i--){ temp[i] *= v[idx]; dp(idx + 1, curr + temp[i] - temp[i] / v[idx], end); temp[i] /= v[idx]; } } signed main(){ 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); cout << (int)ans.size() << "\n"; for(set<int>::iterator it = ans.begin(); it != ans.end(); it++){ cout << (*it) << " "; } }
#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...