# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
161387 | rama_pang | Toys (CEOI18_toy) | C++14 | 2 ms | 252 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;
using lint = long long;
vector<int> factors;
set<lint> ans;
void brute_force(int n, vector<lint> elements) {
if (n == factors.size()) {
lint res = 0;
for (auto i : elements) res += i;
ans.emplace(res);
return;
}
for (auto i = 0; i < elements.size(); i++) {
lint tmp = elements[i];
elements[i] = elements[i] * factors[n] + elements[i] + factors[n];
brute_force(n + 1, elements);
elements[i] = tmp;
}
elements.push_back(factors[n]);
brute_force(n + 1, elements);
return;
}
int main() {
int N; cin >> N;
for (int i = 2; i <= N; i++) {
while (N % i == 0) {
factors.push_back(i - 1);
N /= i;
}
if (i * i > N) {
if (N > 1) factors.push_back(N - 1);
brute_force(0, vector<lint>());
break;
}
}
cout << ans.size() << "\n";
for (auto i : ans) 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... |