B - Attack at the Orbit

Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

Description

Combat spaceship “Rickenbacker” was approaching planet Orkut, the last citadel of the enemy race Shodan. “Rickenbacker” 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 “Orkut-space” rockets on the surface of the planet. All the pads were situated on the small military base on the surface of Orkut.
“Rickenbacker” 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 “Rickenbacker” 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’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 ≤ n ≤ 50 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’s laser can destroy and the minimum distance the origin needs to be moved to. Absolute error of output distance shouldn't exceed 10 −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<stdio.h>
#include<string.h>
#include<iostream>
#include<math.h>
#include<algorithm> using namespace std;
int sum[][];
const double esp=1e-;
int dis(int x,int y){
int xx=min(x,-x);
int yy=min(y,-y);
return xx*xx+yy*yy;
}
int main(){
int n;
while(scanf("%d",&n)!=EOF){
memset(sum,,sizeof(sum));
double x,y;
for(int i=;i<=n;i++){
scanf("%lf%lf",&x,&y);
int tx=(int)(round(x*))%;
int ty=(int)(round(y*))%;
if(tx<)
tx+=;
if(ty<)
ty+=;
sum[tx][ty]++;
}
int ans1=,ans2=;
for(int i=;i<=;i++){
for(int j=;j<=;j++){
if(sum[i][j]>ans1){
ans1=sum[i][j];
ans2=dis(i,j);
}
else if(sum[i][j]==ans1&&dis(i,j)<ans2){
ans2=dis(i,j); }
}
}
printf("%d %.5lf\n",ans1,sqrt(ans2*esp)); }
return ;
}

URAL 1942 Attack at the Orbit的更多相关文章

  1. bnuoj 27987 Record of the Attack at the Orbit (模拟)

    http://www.bnuoj.com/bnuoj/problem_show.php?pid=27987 [题意]:给定坐标输出图形 [题解]:处理坐标上的小技巧 [code]: #include ...

  2. URAL 1944 大水题模拟

    D - Record of the Attack at the Orbit Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format ...

  3. UDP flood UDP Port Denial-of-Service Attack

    https://baike.baidu.com/item/UDP%20flood/5504851 UDPFlood是日渐猖厥的流量型DoS攻击,原理也很简单.常见的情况是利用大量UDP小包冲击DNS服 ...

  4. URAL 1141. RSA Attack RSA加密演算法

    标题来源:URAL 1141. RSA Attack 意甲冠军:给你e n c 并有m^e = c(mod n) 求 m 思路:首先学习RSA算法 here 过程大致是 1.发送的信息是m 2.随机选 ...

  5. ****ural 1141. RSA Attack(RSA加密,扩展欧几里得算法)

    1141. RSA Attack Time limit: 1.0 secondMemory limit: 64 MB The RSA problem is the following: given a ...

  6. URAL 1557 Network Attack 图论,连通性,tarjain,dfs建树,分类讨论 难度:2

    http://acm.timus.ru/problem.aspx?space=1&num=1557 1557. Network Attack Time limit: 2.0 secondMem ...

  7. URAL 1141. RSA Attack(欧拉定理+扩展欧几里得+快速幂模)

    题目链接 题意 : 给你n,e,c,并且知道me ≡ c (mod n),而且n = p*q,pq都为素数. 思路 : 这道题的确与题目名字很相符,是个RSA算法,目前地球上最重要的加密算法.RSA算 ...

  8. Ural 1197 - Lonesome Knight

    The statement of this problem is very simple: you are to determine how many squares of the chessboar ...

  9. 8 Best DDoS Attack Tools (Free DDoS Tool Of The Year 2019)

    #1) HULK Description: HULK stands for HTTP Unbearable Load King. It is a DoS attack tool for the web ...

随机推荐

  1. Vuex基础-Getter

    官方地址:https://vuex.vuejs.org/zh/guide/getters.html Vuex 允许我们在 store 中定义“getter”(可以认为是 store 的计算属性).就像 ...

  2. 记录表TABLE的使用详解

    定义记录表(或索引表)数据类型与记录类型相似,但它是对记录类型的扩展.它可以处理多行记录,类似于高级中的二维数组,使得可以在PL/SQL中模仿数据库中的表. 定义记录表类型的语法如下: 1 2 TYP ...

  3. mysql指定id默认第一

    有个需求 家庭创建人要默认排第一,刚开始用加入家庭的时间排序可以  好简单, 后来加了一个需求 家庭创建人可以转移,结果按时间排序就不行了,又不想去写循环重新排序 就各种百度, 等于就是指定ID排最后 ...

  4. 什么是shell 是不是什么时候都可以使用shell

    因为Shell似乎是各UNIX系统之间通用的功能,并且经过了POSIX的标准化.因此,Shell脚本只要"用心写"一次,即可应用到很多系统上.因此,之所以要使用Shell脚本是基于 ...

  5. 【jQuery】输入框自带清除按钮

    最近一个项目,需要在输入框时右边出现“X”标志,点击X即可清空,主要使用了click和blur事件,难点在于点击‘X’时,input框获得焦点时出现“X”标志,而点击"x"标志时i ...

  6. attention发展历史及其相应论文

    这个论文讲述了attention机制的发展历史以及在发展过程的变体-注意力机制(Attention Mechanism)在自然语言处理中的应用 上面那个论文提到attention在CNN中应用,有一个 ...

  7. [KMP][BZOJ1355][Baltic2009]Radio Transmission

    题面 Description 给你一个字符串,它是由某个字符串不断自我连接形成的. 但是这个字符串是不确定的,现在只想知道它的最短长度是多少. Input 第一行给出字符串的长度,\(1 < L ...

  8. perl语言入门总结-第4章-子程序

    子程序定义和返回值 sub sum{ print "调用了子程序\n"; $a + $b; #后一行为返回值 } ; ; $s =∑ #34 调用子程序 子程序中的参数,参数固定( ...

  9. INSERT⋯ACCEPTING_DUPLICATE_KEYS

    使用ACCEPTING DUPLICATE KEYS时,当插入时发现这条记录已存在时,那么这条记录将不会被insert,后续记录继续执行insert

  10. ABAP News for Release 7.51 – ABAP CDS Client Handling

    Open SQLは自動的クライアント処理をサポートしています. Open SQLでクライアント依存のデータソースにアクセスする時.デフォルトでは現在のクライアントのデータだけが考慮されます. クライア ...