# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
425239 | MOUF_MAHMALAT | Toys (CEOI18_toy) | C++14 | 803 ms | 4516 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 all(s) s.begin(),s.end()
using namespace std;
typedef int ll;
ll n;
set<ll>ans,s;
vector<ll>v;
void best(ll d,ll sum,ll mx)
{
if(d==1)
return void(ans.insert(sum));
for(ll i=0; i<v.size(); i++)
{
if(v[i]>mx)
break;
if(d%v[i]==0)
best(d/v[i],sum+v[i]-1,v[i]);
}
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n;
for(ll i=1; i*i<=n; i++)
if(n%i==0)
{
s.insert(i);
s.insert(n/i);
}
s.erase(s.begin());
for(auto z:s)
v.push_back(z);
best(n,0,n);
cout<<ans.size()<<endl;
for(auto z:ans)
cout<<z<<" ";
return 0;
}
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... |