# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
161385 |
2019-11-02T06:59:34 Z |
rama_pang |
Toys (CEOI18_toy) |
C++14 |
|
2 ms |
376 KB |
#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 << " ";
cout << "\n";
}
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));
~~^~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |