hdoj-1173-Mining

Source: Internet
Author: User
Tags first row

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; 
}    

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.