Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <string>
- #include <math.h>
- #include <climits>
- //#pragma GCC optimize("O3, unroll-loops");
- #include <list>
- #include <map>
- #include <set>
- #include <queue>
- #include <unordered_map>
- #include <unordered_set>
- //#include <chrono>
- //#include <fstream>
- //#include <bits/stdc++.h>
- #define mp make_pair
- #define pb push_back
- #define eb emplace_back
- #define x first
- #define y second
- #define sz(x) (int)x.size()
- #define all(x) begin(x), end(x)
- #define rall(x) rbegin(x), rend(x)
- #define FOR(i,a,b) for (int i = (a); i < (b); i++)
- #define RFOR(i,b,a) for (int i = (b) - 1; i >= (a); i--)
- using namespace std;
- typedef unsigned long long ull;
- typedef long long ll;
- typedef long double ld;
- typedef pair<int, int> pi;
- typedef pair<ll, ll> pl;
- typedef vector<int> veci;
- typedef vector<bool> vecb;
- typedef vector<vector<int>> vvi;
- typedef vector<vector<bool>> vvb;
- const int INF_I = 1e9;
- const ll INF_LL = 1e18;
- int main() {
- /*ifstream cin("in.txt");
- ofstream cout("out.txt");
- auto start_time = chrono::high_resolution_clock::now();*/
- ios::sync_with_stdio(false);
- cin.tie(0);
- cout.tie(0);
- ull n, a, b, w, h;
- cin >> n >> a >> b >> w >> h;
- ull l = 0, r = max(w, h) + 1;
- while (l + 1 < r) {
- ull m = (l + r) / 2;
- if (ull(w / (a + 2 * m)) * ull(h / (b + 2 * m)) >= n)
- l = m;
- else
- r = m;
- }
- r = max(w, h) + 1;
- while (l + 1 < r) {
- ull m = (l + r) / 2;
- if (ull(h / (a + 2 * m)) * ull(w / (b + 2 * m)) >= n)
- l = m;
- else
- r = m;
- }
- cout << l << endl;
- /*auto end_time = chrono::high_resolution_clock::now();
- chrono::duration<double> duration = end_time - start_time;
- cout << duration.count() << "\n";
- cin.close();
- cout.close();*/
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment