# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
619667 | Baray | Toys (CEOI18_toy) | C++17 | 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>
using namespace std;
#define pb push_back
int n;
vector<int> divisors;
int main() {
cin >> n;
for (int i = 1; i * i <= n; i++) {
if (!(n % i))
divisors.pb(i); if (i * i != n) divisors.pb(n / i);
}
sort(divisors.begin(), divisors.end());
vector<vector<int> > v(divisors.size());
v[0].pb(0);
for (int i = 1; i < divisors.size(); i++) {
for (int j = 0; j < i; j++) {
if (!(divisors[i] % divisors[j])) {
for (int x = 0; x < v[j].size(); x++) {
v[i].pb(v[j][x] + divisors[i] / divisors[j] - 1);
}
}
}
sort(v[i].begin(), v[i].end());
v[i].resize(unique(v[i].begin(), v[i].end()) - v[i].begin());
}
cout << v.back().size() << "\n";
for (int i = 0; i < v.back().size(); i++) {
cout << v.back()[i] << " ";
}
}