Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // OK B region 15/16 first day https://informatics.mccme.ru/mod/statements/view3.php?id=18805&chapterid=113097#
- # include <iostream>
- using namespace std;
- int main() {
- int64_t n, a, b, w, h;
- cin >> n >> a >> b >> w >> h;
- int64_t left = 0;
- int64_t right = max(w, h) + 1;
- while (right - left > 1) {
- int64_t d = (left + right) / 2;
- int64_t count_wh = (w / (a + 2 * d)) * (h / (b + 2 * d));
- int64_t count_hw = (w / (b + 2 * d)) * (h / (a + 2 * d));
- if (count_wh >= n || count_hw >= n) {
- left = d;
- } else {
- right = d;
- }
- }
- cout << left;
- return 0;
- }
Add Comment
Please, Sign In to add comment