#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
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));
~~^~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |