Submission #536921

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