# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
383424 | rumen_m | Toys (CEOI18_toy) | C++17 | 1842 ms | 17128 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>
using namespace std;
vector <int> nums;
void solve(int n, int sum, int l)
{
if(n==1){nums.push_back(sum);return;}
for(int i=1;i*i<=n;i++)
{
if(n%i==0)
{
if(i>=l)
{
solve(n/i,sum+i-1,i);
}
if(n/i>=l)
{
solve(i,sum+n/i-1,n/i);
}
}
}
}
vector <int> ans;
void remove_equal()
{
ans.push_back(nums[0]);
int i;
for(i=1;i<nums.size();i++)
{
if(nums[i]!=nums[i-1])ans.push_back(nums[i]);
}
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin>>n;
solve(n,0,2);
sort(nums.begin(),nums.end());
remove_equal();
cout<<ans.size()<<endl;
for(int i = 0;i<ans.size();i++)
cout<<ans[i]<<" ";
cout<<endl;
}
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... |