# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
76962 | IOrtroiii | Toys (CEOI18_toy) | C++14 | 4134 ms | 18148 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;
int n;
vector<int> d;
vector<int> vals;
void brute(int pos,int prd,int sum) {
if (pos == d.size()) return;
if (prd == 1) {
vals.push_back(sum);
return;
}
if (prd < d[pos]) return;
if (prd % d[pos] == 0) brute(pos, prd / d[pos], sum + d[pos] - 1);
brute(pos + 1, prd, sum);
}
int main() {
scanf("%d", &n);
for (int i = 2; i * i <= n; ++i) if (n % i == 0) {
d.push_back(i);
if (i * i < n) d.push_back(n / i);
}
sort(d.begin(), d.end());
d.push_back(n);
brute(0, n, 0);
sort(vals.begin(), vals.end());
vals.resize(unique(vals.begin(), vals.end()) - vals.begin());
cout << vals.size() << '\n';
for (int i : vals) cout << i << ' ';
}
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... |