URAL 1942 Attack at the Orbit
2015-07-30 08:51
399 查看
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
%26nbsp;
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
input | output |
---|---|
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); 9873 } } } printf("%d %.5lf\n",ans1,sqrt(ans2*esp)); } return 0; }
%26nbsp;
相关文章推荐
- 在 Linux 命令行中使用和执行 PHP 代码(二):12 个 PHP 交互性 shell 的用法
- geant4.10.1.p02例子学习之-hadrontherapy
- hdu 5324 Boring Class(15多校第三场1009)(cdq分治)
- 中小型网络系统总体规划与设计方法(二 )
- URAL 1942 Attack at the Orbit
- URAL 1942 Attack at the Orbit
- HTTP长连接与短连接
- URAL 1942 Attack at the Orbit
- Mysql设置允许外网访问(图文)
- Javascript Array操作函数整理
- swift学习之UI控件(一)
- ios指针第二天
- URAL 1942 Attack at the Orbit
- URAL 1942 Attack at the Orbit
- URAL 1942 Attack at the Orbit
- URAL 1942 Attack at the Orbit
- oc基础
- URAL 1942 Attack at the Orbit
- iOS UI01_Label
- HTTP1.1中CHUNKED编码解析