Submission #934349

#TimeUsernameProblemLanguageResultExecution timeMemory
934349tamir1Toys (CEOI18_toy)C++14
100 / 100
3031 ms86512 KiB
#include<bits/stdc++.h> #define ll int using namespace std; ll n,i,j,m,x,y; vector<ll> a; set<ll> s[2000],t; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for(i=1;i*i<=n;i++){ if(n%i!=0) continue; if(i*i==n){ a.push_back(i); continue; } a.push_back(i); a.push_back(n/i); } sort(a.begin(),a.end()); m=a.size(); s[0].insert(0); for(i=0;i<m;i++){ x=a[i]; for(j=i+1;j<m;j++){ y=a[j]; if(y%x!=0) continue; ll add=y/x-1; for(ll l:s[i]) s[j].insert(l+add); } } cout << s[m-1].size() << "\n"; for(ll i:s[m-1]) 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...