T3000

Untitled

Mar 23rd, 2022
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. using ll = unsigned long long;
  5.  
  6. int main()
  7. {
  8.     long double s1 = 0, s2 = 0;
  9.     long double x1, y1, x2, y2, x3, y3, x4, y4;
  10.     cout << setprecision(7);
  11.     cout << fixed;
  12.     cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
  13.     if (x1 == x2)
  14.     {
  15.         s1 = max(y1, y2) - min(y1, y2);
  16.     }
  17.     else if (y1 == y2)
  18.     {
  19.         s1 = max(x1, x2) - min(x1, x2);
  20.     }
  21.     else
  22.     {
  23.         long double h1 = max(y1, y2) - min(y1, y2), h2 = max(x1, x2) - min(x1, x2);
  24.         h1 = h1 * h1;
  25.         h2 = h2 * h2;
  26.         s1 = sqrt(h1 + h2);
  27.     }
  28.     if (x3 == x4)
  29.     {
  30.         s2 = max(y3, y4) - min(y3, y4);
  31.     }
  32.     else if (y3 == y4)
  33.     {
  34.         s2 = max(x3, x4) - min(x3, x4);
  35.     }
  36.     else
  37.     {
  38.         long double h3 = max(y3, y4) - min(y3, y4), h4 = max(x3, x4) - min(x3, x4);
  39.         h3 = h3 * h3;
  40.         h4 = h4 * h4;
  41.         s2 = sqrt(h3 + h4);
  42.     }
  43.     cout << max(s1, s2) << endl;
  44.     return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment