# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
490950 | SanguineChameleon | Toys (CEOI18_toy) | C++14 | 5100 ms | 1480 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;
const bool read_file = false;
const char fi[] = "XX.INP";
const char fo[] = "XX.OUT";
void set_up() {
if (read_file) {
freopen(fi, "r", stdin);
freopen(fo, "w", stdout);
}
cin.clear();
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
void just_do_it();
int main() {
set_up();
just_do_it();
}
set<long long> s;
long long n;
vector<long long> f;
void backtrack(long long cc, long long cp, long long cs) {
if (cc == 1) {
s.insert(cs);
return;
}
for (auto pp: f) {
if (pp >= cp) {
if (cc % pp == 0) {
backtrack(cc / pp, pp, cs + pp - 1);
}
}
else {
return;
}
}
}
void just_do_it() {
cin >> n;
for (long long ff = 1; ff * ff <= n; ff++) {
if (n % ff == 0) {
if (ff * ff == n) {
f.push_back(ff);
}
else {
f.push_back(ff);
f.push_back(n / ff);
}
}
}
sort(f.begin(), f.end(), greater<long long>());
backtrack(n, 2, 0);
cout << s.size() << endl;
for (auto x: s) {
cout << x << " ";
}
}
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... |