Submission #424852

#TimeUsernameProblemLanguageResultExecution timeMemory
424852MOUF_MAHMALATToys (CEOI18_toy)C++14
19 / 100
1 ms332 KiB
#include<bits/stdc++.h> #define all(s) s.begin(),s.end() using namespace std; typedef int ll; ll n; vector<ll>v,op; bool b[100009],dp[17][1<<17]; set<ll>s; void best(ll d,ll sum) { if(d==n) { if(b[sum]==0) s.insert(sum),b[sum]=1; return; } if(dp[d][sum]) return; dp[d][sum]=1; for(ll i=0; i<17; i++) { sum-=op[i]-1; op[i]*=v[d]; sum+=op[i]-1; best(d+1,sum); sum-=op[i]-1; op[i]/=v[d]; sum+=op[i]-1; } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n; for(ll i=2; i*i<=n; i++) { while(n%i==0) n/=i,v.push_back(i); } if(n>1) v.push_back(n); n=v.size(); //cout<<n<<endl; for(ll i=0; i<17; i++) op.push_back(1); best(0,0); cout<<s.size()<<endl; for(auto z:s) cout<<z<<" "; return 0; }
#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...