# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
124053 | semiauto | Toys (CEOI18_toy) | C++14 | 2641 ms | 4616 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 se second
#define fi first
using namespace std;
int n,i;
priority_queue <int> ans;
vector <int> d;
unordered_map <int,bool> mymap;
void go(int x,int s,int k) {
if (x==1) {
if (!mymap[s])
{
ans.push(-s);
mymap[s]=1;
}
return;
}
int i;
for (i=k;i<d.size();i++)
{if (!(x%d[i]))
go(x/d[i],s+d[i]-1,i);
if (d[i]>x)break;}
}
int main() {
cin>>n;
for (i=2;(i*i)<=n;i++)
if (!(n%i))
d.push_back(i);
for (i=d.size()-1;i>=0;i--)
if (d[i]*d[i]<n)
d.push_back(n/d[i]);
d.push_back(n);
go(n,0,0);
cout<<ans.size()<<endl;
while (ans.size()) {
printf("%d ",(-(ans.top())));
ans.pop();
}
cout<<endl;
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... |