Advertisement
bibaboba12345

Untitled

Nov 13th, 2022
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. // clang-format off
  2. #define _CRT_SECURE_NO_WARNINGS
  3. #include <iostream>
  4. #include <iomanip>
  5. #include <bitset>
  6. #include <vector>
  7. #include <algorithm>
  8. #include <random>
  9. #include <map>
  10. #include <string>
  11. #include <set>
  12. #include <deque>
  13. #include <cassert>
  14.  
  15.  
  16. const int N = 2e5 + 7, A = 26, C = 2, MOD = 998244353;
  17. const long long INF = 1e18;
  18. using namespace std;
  19. using ll = long long;
  20. using ld = long double;
  21.  
  22. const ld EPS = 1e-9;
  23.  
  24. long double w1, h1, w2, h2;
  25. long double ans = 1e18;
  26. void process() {
  27. if (h1 <= h2) {
  28. if (w2 <= w1) {
  29. ans = min(ans, (w1 - w2) * h1 / 2);
  30. }
  31. else {
  32. ans = 0;
  33. }
  34. }
  35. else {
  36. if (w2 >= w1) {
  37. ans = min(ans, (h1 - h2) * w1 / 2);
  38. }
  39. else {
  40. ans = min(ans, (h1 * w1) - h2 * w2);
  41. }
  42. }
  43. }
  44.  
  45. void solve() {
  46. cin >> w1 >> h1 >> w2 >> h2;
  47.  
  48. process();
  49. swap(h1, w1);
  50. process();
  51. swap(h2, w2);
  52. process();
  53. swap(h1, w1);
  54. process();
  55. cout <<fixed << setprecision(1) << ans;
  56. }
  57.  
  58. signed main() {
  59. #ifdef _DEBUG
  60. freopen("input.txt", "r", stdin);
  61. #else
  62. std::ios::sync_with_stdio(false);
  63. cin.tie(0);
  64. #endif
  65. int t;
  66. t = 1;
  67. while (t--) {
  68. solve();
  69. }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement