Submission #536950

#TimeUsernameProblemLanguageResultExecution timeMemory
536950Hydroxic_AcidToys (CEOI18_toy)C++17
19 / 100
349 ms262144 KiB
#include <iostream> #include <algorithm> #include <vector> #include <cmath> #include <map> using namespace std; #define int long long int n; vector<int> v; vector<int> ans; int temp[100000]; void dp(int idx, int curr, int end){ if(idx == (int)v.size()){ ans.push_back(curr - end - 1); return; } 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]; } temp[end + 1] = v[idx]; dp(idx + 1, curr + v[idx], end + 1); temp[end + 1] = 0; } 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); sort(ans.begin(), ans.end()); int cnt = 0; for(int i = 0; i < (int)ans.size(); i++){ if(i == 0 || ans[i - 1] != ans[i]) cnt++; } cout << cnt << "\n"; for(int i = 0; i < (int)ans.size(); i++){ if(i == 0 || ans[i - 1] != ans[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...