# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
714435 | stevancv | Toys (CEOI18_toy) | C++14 | 2949 ms | 4448 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>
#define ll long long
#define ld long double
#define sp ' '
#define en '\n'
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
using namespace std;
const int N = 1e5 + 2;
const int M = 1e6 + 2;
const ll linf = 1e18;
vector<int> d;
set<int> ans;
int kolko;
void Resi(int i, int n, int s) {
if (n == 1) {
ans.insert(s);
kolko++;
return;
}
if (i == d.size() || n < d[i]) return;
if (n % d[i] == 0) Resi(i, n / d[i], s + d[i] - 1);
Resi(i + 1, n, s);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n; cin >> 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);
}
}
d.push_back(n);
sort(d.begin(), d.end());
Resi(0, n, 0);
cout << ans.size() << en;
for (int i : ans) cout << i << sp;
cout << en;
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... |