Advertisement
LEGEND2004

Longest Segment

Aug 1st, 2023
997
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define F first
  5. #define S second
  6. #define int long long
  7. #define double long double
  8.  
  9. int distance(int x1 , int y1 , int x2, int y2){
  10.     int d = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
  11.     return d;
  12. }
  13.  
  14. signed main()
  15. {
  16.     int n;
  17.     cin >> n;
  18.     vector<pair<int , int> > v(n);
  19.     for(int i = 0; i < n; i++){
  20.         cin >> v[i].F >> v[i].S;
  21.     }
  22.     int ans = 0;
  23.     for(int i = 0; i < n; i++){
  24.         for(int j = i + 1; j < n; j++){
  25.             ans = max(ans , distance(v[i].F , v[i].S , v[j].F , v[j].S));
  26.         }
  27.     }
  28.     double sq = sqrtl(ans);
  29.     cout << setprecision(6) << fixed << sq << endl;
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement