daily pastebin goal
46%
SHARE
TWEET

Untitled

a guest Jan 24th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <map>
  3. #include <set>
  4. #include <cmath>
  5. #include <algorithm>
  6. #include <iomanip>
  7. #include <vector>
  8. #include <queue>
  9. #include <fstream>
  10. using namespace std;
  11. void stress();
  12. int main()
  13. {
  14.     ios::sync_with_stdio(0);
  15.     cin.tie(0);
  16. //    srand(time(0));
  17.     stress();
  18. }
  19.  
  20. #define int long long
  21.  
  22. void stress() {
  23.     ifstream cin("space.in");
  24.     ofstream cout("space.out");
  25.    int n,a,b,w,h;
  26.    cin >> n >> a >> b >> w >> h;
  27.    int l = 0, r = 1e18;
  28.    while (l<r)
  29.    {
  30.        int mid = l+r>>1;
  31.        int can = (w/(a+2* mid)) *(h/(b+2*mid));
  32.        if (can>=n)
  33.            l = mid+1;
  34.        else
  35.            r = mid;
  36.    }
  37.    int ans = l-1;
  38.     l = 0, r = 1e18;
  39.     while (l<r)
  40.     {
  41.         int mid = l+r>>1;
  42.         int can = (h/(a+2* mid)) *(w/(b+2*mid));
  43.         if (can>=n)
  44.             l = mid+1;
  45.         else
  46.             r = mid;
  47.     }
  48.     cout << max(ans,l-1);
  49. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top