제출 #425044

#제출 시각아이디문제언어결과실행 시간메모리
425044MOUF_MAHMALATToys (CEOI18_toy)C++14
59 / 100
5034 ms1604 KiB
#include<bits/stdc++.h> #define all(s) s.begin(),s.end() using namespace std; typedef int ll; ll n,x,to[100]; vector<ll>v; set<ll>s; void best(ll d,ll mask,ll k,bool is,ll sum) { if(mask==(1<<n)-1) { sum+=k-1; s.insert(sum); return; } if(d==n) return void(best(0,mask,1,0,sum+k-1)); if((1<<d)&mask) return void(best(d+1,mask,k,is,sum)); best(d+1,(1<<d)|mask,k*v[d],1,sum); if(is) best(to[d],mask,k,1,sum); } 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(); to[n-1]=n; for(ll i=n-2; i>=0; i--) { if(v[i]!=v[i+1]) to[i]=i+1; else to[i]=to[i+1]; // cout<<to[i]<<" "; } best(0,0,1,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...