Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- int main()
- {
- int n;
- cin >> n;
- double X[n], Y[n];
- for(int i = 0; i < n; i++){
- cin >> X[i] >> Y[i];
- }
- double mx = 0;
- int mxIndexOne = 0, mxIndexTwo = 0;
- for(int i = 1; i < n; i++){
- double r = sqrt(pow((X[i] - X[0]), 2) + pow((Y[i] - Y[0]), 2));
- //cout << "Distance between point number 1 and number " << i + 1 << " equals " << r << endl;
- if(r > mx) {
- mx = r;
- mxIndexOne = i;
- }
- }
- for(int i = 0; i < n; i++){
- double r = sqrt(pow((X[i] - X[mxIndexOne]), 2) + pow((Y[i] - Y[mxIndexOne]), 2));
- //cout << "Distance between point number " << mxIndexOne + 1 << " and number " << i + 1 << " equals " << r << endl;
- if(r > mx) {
- mx = r;
- mxIndexTwo = i;
- }
- }
- cout << mxIndexOne + 1 << " " << mxIndexTwo + 1;
- return 0;
- }
- /* тест (ответ "3 4")
- 5
- 1 2 5 -4 -1326 -5928 124 15 0 0
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement