您的位置:首页 > 其它

URAL 1942 Attack at the Orbit

2015-07-30 08:50 351 查看
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
Submit

Status
Practice
URAL 1942

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;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: