Problem Description one day Gameboy play Warcraft RPG. One task is to build a base on a small, gold-rich circular island that collects all the gold deposits on the island at the fastest speed. There are N (0<n<1000000) gold deposits on the island, and the amount of mineral deposits in each gold mine is equal. And the island's topography is very flat, so the base can be built anywhere on the island, and the mining speed of each gold mine is only related to the length of the mineral-to-base distance. In order not to let this task too boring, the game designers to the island to a "magic", the rule of the miners on the island only South is Xi Jongdong walk. That means the miners can't walk on the island in an oblique way.
This small island is described in a two-dimensional Cartesian coordinate system.
Your job is to help Gameboy find a place to build a base so that the miners can pick up all the mines at the fastest speed.
Input data has multiple groups. The first row of each set of data is a positive integer n (0<n<1000000), indicating that there are N gold deposits on the island. In the next n rows, each row has two real numbers x, y, representing the coordinates of one of the gold mines. N=0 indicates the end of the input data.
Output each set of input data corresponds to a row of output, outputting two real numbers x, Y (two digits after the decimal point), that is, the location coordinates of the construction site you find. If the coordinates are not unique, you can select one output.
Sample Input
4 1.0 1.0 3.0 1.0 3.0 3.0 1.0 3.0 0
Sample Output
2.00 2.00
Very simple, in fact, the x-coordinate and the y-coordinate sorting, and then find the median is the answer ...
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn=1000005;
Double A[MAXN],B[MAXN];
int main ()
{
int i,n;
while (scanf ("%d", &n), N)
{for
(i=0;i<n;i++)
scanf ("%lf%lf", &a[i],&b[i]);
Sort (a,a+n);
Sort (b,b+n);
printf ("%.2lf%.2lf\n", A[N/2],B[N/2]);
}
return 0;
}