# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
934314 | tamir1 | Toys (CEOI18_toy) | C++14 | 1 ms | 344 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define ll int
using namespace std;
ll n,i,j,m,x,y;
vector<ll> a,b;
unordered_map<ll,ll> mp;
int main(){
/*ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);*/
//cin >> n;
scanf("%d",&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);
b.push_back(n/i);
}
m=b.size();
for(i=m-1;i>=0;i--) a.push_back(b[i]);
m=a.size();
set<ll> s[m];
for(i=0;i<m;i++){
mp[a[i]]=i;
x=a[i];
s[i].insert(x-1);
for(j=1;a[j]*a[j]<=x;j++){
y=a[j];
if(x%y!=0) continue;
for(ll l:s[mp[y]]){
for(ll r:s[mp[x/y]]){
s[i].insert(l+r);
}
}
}
}
//cout << s[m-1].size() << "\n";
printf("%d\n",s[m-1].size());
for(ll i:s[m-1]) printf("%d ",i);
//cout << i << " ";
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |