diff options
| author | Richard Qin <richard.qin.x@gmail.com> | 2026-06-17 00:46:01 +0800 |
|---|---|---|
| committer | Richard Qin <richard.qin.x@gmail.com> | 2026-06-17 00:46:01 +0800 |
| commit | c5b4420399e2596418b05c1867f3e78e52f0fb1e (patch) | |
| tree | e4e8abfee46c03244560b6311279548a8c3a912c | |
| parent | 4634308d50b5b1e4f993c495a8bb51edac9f94bd (diff) | |
| download | csp-c5b4420399e2596418b05c1867f3e78e52f0fb1e.tar.gz csp-c5b4420399e2596418b05c1867f3e78e52f0fb1e.tar.xz | |
[42] apple
| -rw-r--r-- | 42/apple.cc | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/42/apple.cc b/42/apple.cc new file mode 100644 index 0000000..b9cce28 --- /dev/null +++ b/42/apple.cc @@ -0,0 +1,40 @@ +#include <bits/stdc++.h> +#include <cstdint> +using namespace std; + +uint64_t n, k, m; + +bool can_live(uint64_t robot_num) { + uint64_t total_apple = n; + for (int day = 1; day <= m; ++day) { + uint64_t rot = (total_apple * k + 99) / 100; + total_apple -= rot; + if (total_apple < robot_num) { + return false; + } + total_apple -= robot_num; + } + return true; +} + +int main() { + ios::sync_with_stdio(false); + cin.tie(nullptr); + cin >> n >> k >> m; + + uint64_t left = 0; + uint64_t right = n / m; + uint64_t res = 0; + + while (left <= right) { + uint64_t mid = left + (right - left) / 2; + if (can_live(mid)) { + res = mid; + left = mid + 1; + } else { + right = mid - 1; + } + } + cout << res << "\n"; + return 0; +} |
