URAL 1942 Attack at the Orbit

B - Attack at the Orbit
Time Limit:1000MS%26nbsp;%26nbsp;%26nbsp;%26nbsp; Memory Limit:65536KB%26nbsp;%26nbsp;%26nbsp;%26nbsp; 64bit IO Format:%I64d %26amp; %I64u

Description

Combat spaceship %26ldquo;Rickenbacker%26rdquo; was approaching planet Orkut, the last citadel of the enemy race Shodan. %26ldquo;Rickenbacker%26rdquo; had all the advantage, for the whole space force of Shodans had been already destroyed. But then the frightening message came: there were several launching pads with %26ldquo;Orkut-space%26rdquo; rockets on the surface of the planet. All the pads were situated on the small military base on the surface of Orkut.
%26ldquo;Rickenbacker%26rdquo; is equipped with a long-range laser able to destroy the pad before the spaceship enters the dangerous area around the planet. The aiming system of the laser is bound to a rectangular Cartesian system. Unfortunately, the laser can shoot at targets both coordinates of which are integers.
Captain of %26ldquo;Rickenbacker%26rdquo; received the exact coordinates of every pad. Now he wants to readjust the laser once before shooting by moving the origin to another point on the surface so that the laser could strike the largest amount of pads. The captain can%26rsquo;t rotate the weapon aiming system.
Help the captain choose the new position of the origin. If there are several such positions, choose the one which is closest to the initial origin.

Input

The first line contains an integer n (1 %26le; n %26le; 50%26nbsp;000) that is the number of the launching pads. The following n lines contain the coordinates of these pads that are real numbers not exceeding 100 by absolute value and are given with at most three digits after decimal point. Coordinates of different pads may coincide.

Output

Output two numbers: the maximum amount of pads which Rickenbacker%26rsquo;s laser can destroy and the minimum distance the origin needs to be moved to. Absolute error of output distance shouldn't exceed 10 %26minus;5.

Sample Input

inputoutput
3
0.500 0.200
0.500 0.500
-0.500 0.200
2 0.53852
2          
1.000 1.000
1.000 1.000
2 0.00000
#include%26lt;stdio.h%26gt;
#include%26lt;string.h%26gt;
#include%26lt;iostream%26gt;
#include%26lt;math.h%26gt;
#include%26lt;algorithm%26gt;

using namespace std;
int sum[2000][2000];
const double esp=1e-6;
int dis(int x,int y){
     int xx=min(x,1000-x);
     int yy=min(y,1000-y);
     return xx*xx+yy*yy;
}
int main(){
    int n;
    while(scanf("%d",%26amp;n)!=EOF){
            memset(sum,0,sizeof(sum));
        double x,y;
        for(int i=1;i%26lt;=n;i++){
            scanf("%lf%lf",%26amp;x,%26amp;y);
            int tx=(int)(round(x*1000))%1000;
            int ty=(int)(round(y*1000))%1000;
            if(tx%26lt;0)
                tx+=1000;
            if(ty%26lt;0)
                ty+=1000;
            sum[tx][ty]++;
        }
        int ans1=0,ans2=999999999;
        for(int i=0;i%26lt;=1000;i++){
            for(int j=0;j%26lt;=1000;j++){
                if(sum[i][j]%26gt;ans1){
                    ans1=sum[i][j];
                    ans2=dis(i,j);
                }
                else if(sum[i][j]==ans1%26amp;%26amp;dis(i,j)%26lt;ans2){
                    ans2=dis(i,j);

                }
            }
        }
        printf("%d %.5lf\n",ans1,sqrt(ans2*esp));

    }
    return 0;
}

%26nbsp;







  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值