aboutsummaryrefslogtreecommitdiff
path: root/42/apple.cc
blob: b9cce280eb6c05dec1b8f0f5a9bf75b1c73647ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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;
}