Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // clang-format off
- #define _CRT_SECURE_NO_WARNINGS
- #include <iostream>
- #include <iomanip>
- #include <bitset>
- #include <vector>
- #include <algorithm>
- #include <random>
- #include <map>
- #include <string>
- #include <set>
- #include <deque>
- #include <cassert>
- const int N = 2e5 + 7, A = 26, C = 2, MOD = 998244353;
- const long long INF = 1e18;
- using namespace std;
- using ll = long long;
- using ld = long double;
- const ld EPS = 1e-9;
- long double w1, h1, w2, h2;
- long double ans = 1e18;
- void process() {
- if (h1 <= h2) {
- if (w2 <= w1) {
- ans = min(ans, (w1 - w2) * h1 / 2);
- }
- else {
- ans = 0;
- }
- }
- else {
- if (w2 >= w1) {
- ans = min(ans, (h1 - h2) * w1 / 2);
- }
- else {
- ans = min(ans, (h1 * w1) - h2 * w2);
- }
- }
- }
- void solve() {
- cin >> w1 >> h1 >> w2 >> h2;
- process();
- swap(h1, w1);
- process();
- swap(h2, w2);
- process();
- swap(h1, w1);
- process();
- cout <<fixed << setprecision(1) << ans;
- }
- signed main() {
- #ifdef _DEBUG
- freopen("input.txt", "r", stdin);
- #else
- std::ios::sync_with_stdio(false);
- cin.tie(0);
- #endif
- int t;
- t = 1;
- while (t--) {
- solve();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement