Submission #746553

#TimeUsernameProblemLanguageResultExecution timeMemory
746553amirhoseinfar1385Toys (CEOI18_toy)C++17
100 / 100
1955 ms87340 KiB
#include<bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin>>n; vector<int>fake; map<int,int>mp; int fn=n; for(long long i=1;i*i<=fn;i++){ if(fn%i==0){ fake.push_back(i); if(i*i!=fn){ fake.push_back(fn/i); } } } sort(fake.begin(),fake.end()); int sz=(int)fake.size(); vector<set<int>>st(sz+1); vector<vector<int>>allv(sz+1); for(int i=1;i<sz;i++){ for(int j=0;j<sz;j++){ if(fake[j]%fake[i]==0){ allv[j].push_back(i); } } } for(int i=0;i<sz;i++){ mp[fake[i]]=i; } //cout<<"salam"<<endl; st[0].insert(0); for(int i=1;i<sz;i++){ //cout<<i<<" "<<fake[i]<<endl; for(auto x:allv[i]){ int z=fake[i]/fake[x]; int w=mp[z]; for(auto y:st[w]){ st[i].insert(fake[x]-1+y); } } } int sza=st[sz-1].size(); cout<<sza<<"\n"; for(auto x:st[sz-1]){ cout<<x<<" "; } cout<<'\n'; }
#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...