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;
map<tuple<int, lint, lint>, bool> memo;
void brute_force(int n = 0, lint now = 0, lint sum = 0) {
if (n == factors.size()) return void(ans.emplace(now + sum));
// if (n >= 20) {
// if (memo[make_tuple(n, now, sum)]) return;
// memo[make_tuple(n, now, sum)] = true;
// }
brute_force(n + 1, now * factors[n] + now + factors[n], sum);
brute_force(n + 1, now, sum + factors[n]);
brute_force(n + 1, 0, now + sum + factors[n]);
brute_force(n + 1, factors[n], now + sum);
}
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();
break;
}
}
cout << ans.size() << "\n";
for (auto i : ans) cout << i << " ";
}
Compilation message (stderr)
toy.cpp: In function 'void brute_force(int, lint, lint)':
toy.cpp:10:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (n == factors.size()) return void(ans.emplace(now + sum));
~~^~~~~~~~~~~~~~~~~
# | 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... |