Submission #537964

#TimeUsernameProblemLanguageResultExecution timeMemory
537964TaylorSwiftFangirlToys (CEOI18_toy)C++17
39 / 100
434 ms262144 KiB
#include <bits/stdc++.h> using namespace std; vector<int> f; int m; vector<vector<int> > comb(int x) { if(x==0) { vector<int>v{f[0]}; return (vector<vector<int> >){v}; } vector<vector<int> > a = comb(x-1), b; int k = a.size(); for(int i=0; i<k; i++) { a[i].push_back(f[x]); b.push_back(a[i]); a[i].pop_back(); } for(int i=0; i<k; i++) { for(int j=0; j<(int)a[i].size();j++) { if(j>0 && a[i][j]==a[i][j-1]) continue; a[i][j]*=f[x]; b.push_back(a[i]); a[i][j]/=f[x]; } } return b; } int main() { int n; cin >> n; if(n==1) { cout << "1\n0"; return 0; } for(int i=2; i*i<=n; i++) { while(n%i==0) { f.push_back(i); n/=i; } } if(n!=1) f.push_back(n); vector<vector<int> > v = comb(f.size()-1); set<int> s; for(auto i : v) { int tot = 0; for(auto j : i) tot += j-1; s.insert(tot); } cout << s.size() << '\n'; for(auto i : s) { cout << 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...