kdzhr

Untitled

Jan 13th, 2020
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1. // OK B region 15/16 first day https://informatics.mccme.ru/mod/statements/view3.php?id=18805&chapterid=113097#
  2.  
  3. # include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.     int64_t n, a, b, w, h;
  9.     cin >> n >> a >> b >> w >> h;
  10.     int64_t left = 0;
  11.     int64_t right = max(w, h) + 1;
  12.     while (right - left > 1) {
  13.         int64_t d = (left + right) / 2;
  14.         int64_t count_wh = (w / (a + 2 * d)) * (h / (b + 2 * d));
  15.         int64_t count_hw = (w / (b + 2 * d)) * (h / (a + 2 * d));
  16.         if (count_wh >= n || count_hw >= n) {
  17.             left = d;
  18.         } else {
  19.             right = d;
  20.         }
  21.     }
  22.     cout << left;
  23.     return 0;
  24. }
Add Comment
Please, Sign In to add comment