# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
654048 | MasterTaster | Toys (CEOI18_toy) | C++14 | 0 ms | 0 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 <iostream>
#include <vector>
#define ll long long
#define pb push_back
using namespace std;
int n;
vector<ll> svi, ress;
void dfs(int x, vector<ll> &d, int sum)
{
if (x==1) return;
ress.pb(sum+x-1);
vector<ll> dd;
for (int i=0; i<d.size(); i++) if (x%d[i]==0) dd.pb(d[i]);
for (int i=0; i<dd.size(); i++)
{
if (x/dd[i]>=dd[i])
dfs(x/dd[i], dd, sum+dd[i]-1);
}
}
bool bio[100010];
int main() {
int n; cin>>n;
for (ll i=2; i*i<=n; i++)
if (n%i==0) svi.pb(i);
dfs(n, svi, 0);
vector<ll> r;
for (int i=0; i<ress.size(); i++) if (!bio[ress[i]]) { bio[ress[i]]=true; r.pb(ress[i]); }
cout<<r.size()<<endl;
sort(r.begin(), r.end());
for (int i=0; i<r.size(); i++) cout<<r[i]<<" ";
}