# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
917913 | PM1 | Toys (CEOI18_toy) | C++17 | 1 ms | 348 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;
#define ll long long
int n;
ll sum=1,res=0;
vector<int>v,ans;
void solve(int p=0){
if(sum==n){
ans.push_back(res);
return ;
}
for(;p<v.size();p++){
if(sum*v[p]>n)return;
sum*=v[p];
res+=v[p]-1;
solve(p);
sum/=v[p];
res-=v[p]-1;
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n;
int num=n;
for(int i=2;i*i<=n;i++){
if(num%i)continue;
v.push_back(i);
if(i*i<n)
v.push_back(n/i);
}
v.push_back(n);
sort(v.begin(),v.end());
solve();
sort(ans.begin(),ans.end());
ans.resize(unique(v.begin(),v.end())-v.begin());
cout<<ans.size()<<'\n';
for(auto i:ans)
cout<<i<<" ";
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... |