Raslboyy

Untitled

Jan 22nd, 2020
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.77 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <string>
  5. #include <math.h>
  6. #include <climits>
  7.  
  8. //#pragma GCC optimize("O3, unroll-loops");
  9.  
  10. #include <list>
  11. #include <map>
  12. #include <set>
  13. #include <queue>
  14. #include <unordered_map>
  15. #include <unordered_set>
  16.  
  17. //#include <chrono>
  18. //#include <fstream>
  19. //#include <bits/stdc++.h>
  20.  
  21. #define mp make_pair
  22. #define pb push_back
  23. #define eb emplace_back
  24. #define x first
  25. #define y second
  26. #define sz(x) (int)x.size()
  27. #define all(x) begin(x), end(x)
  28. #define rall(x) rbegin(x), rend(x)
  29. #define FOR(i,a,b) for (int i = (a); i < (b); i++)
  30. #define RFOR(i,b,a) for (int i = (b) - 1; i >= (a); i--)
  31.  
  32. using namespace std;
  33.  
  34. typedef unsigned long long ull;
  35. typedef long long ll;
  36. typedef long double ld;
  37. typedef pair<int, int> pi;
  38. typedef pair<ll, ll> pl;
  39. typedef vector<int> veci;
  40. typedef vector<bool> vecb;
  41. typedef vector<vector<int>> vvi;
  42. typedef vector<vector<bool>> vvb;
  43.  
  44. const int INF_I = 1e9;
  45. const ll INF_LL = 1e18;
  46.  
  47. int main() {
  48.     /*ifstream cin("in.txt");
  49.     ofstream cout("out.txt");
  50.     auto start_time = chrono::high_resolution_clock::now();*/
  51.  
  52.     ios::sync_with_stdio(false);
  53.     cin.tie(0);
  54.     cout.tie(0);
  55.  
  56.     ull n, a, b, w, h;
  57.     cin >> n >> a >> b >> w >> h;
  58.     ull l = 0, r = max(w, h) + 1;
  59.     while (l + 1 < r) {
  60.         ull m = (l + r) / 2;
  61.         if (ull(w / (a + 2 * m)) * ull(h / (b + 2 * m)) >= n)
  62.             l = m;
  63.         else
  64.             r = m;
  65.     }
  66.     r = max(w, h) + 1;
  67.     while (l + 1 < r) {
  68.         ull m = (l + r) / 2;
  69.         if (ull(h / (a + 2 * m)) * ull(w / (b + 2 * m)) >= n)
  70.             l = m;
  71.         else
  72.             r = m;
  73.     }
  74.     cout << l << endl;
  75.  
  76.    
  77.     /*auto end_time = chrono::high_resolution_clock::now();
  78.     chrono::duration<double> duration = end_time - start_time;
  79.     cout << duration.count() << "\n";
  80.     cin.close();
  81.     cout.close();*/
  82.     return 0;
  83. }
Advertisement
Add Comment
Please, Sign In to add comment