Submission #161385

#TimeUsernameProblemLanguageResultExecution timeMemory
161385rama_pangToys (CEOI18_toy)C++14
0 / 100
2 ms376 KiB
#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 (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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...