daily pastebin goal
74%
SHARE
TWEET

12

a guest Mar 21st, 2019 43 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int n;
  9.     cin >> n;
  10.     double X[n], Y[n];
  11.     for(int i = 0; i < n; i++){
  12.         cin >> X[i] >> Y[i];
  13.     }
  14.     double mx = 0;
  15.     int mxIndexOne = 0, mxIndexTwo = 0;
  16.     for(int i = 1; i < n; i++){
  17.         double r = sqrt(pow((X[i] - X[0]), 2) + pow((Y[i] - Y[0]), 2));
  18.         //cout << "Distance between point number 1 and number " << i + 1 << " equals " << r << endl;
  19.         if(r > mx) {
  20.             mx = r;
  21.             mxIndexOne = i;
  22.         }
  23.     }
  24.     for(int i = 0; i < n; i++){
  25.         double r = sqrt(pow((X[i] - X[mxIndexOne]), 2) + pow((Y[i] - Y[mxIndexOne]), 2));
  26.         //cout << "Distance between point number " << mxIndexOne + 1 << " and number " << i + 1 << " equals " << r << endl;
  27.         if(r > mx) {
  28.             mx = r;
  29.             mxIndexTwo = i;
  30.         }
  31.     }
  32.     cout << mxIndexOne + 1 << " " << mxIndexTwo + 1;
  33.     return 0;
  34. }
  35.  
  36. /* тест (ответ "3 4")
  37. 5
  38. 1 2  5 -4  -1326 -5928  124 15  0 0
  39. */
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top