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. Android内购订单验证 --- nodejs实现

    主代码: function AndroidPlayVerify(inappPurchaseData, inappDataSignature) { let verify = crypto.createV ...

  2. strak组件(8):基本增删改查实现及应用和排序

    效果图: 新增函数: def reverse_common_url(self, name, *args, **kwargs) 反向生成url,需要传增删改的url作为参数,携带原参数 def reve ...

  3. python 函数的嵌套 和 作用域链

    # def max(a,b): # return a if a>b else b # # def the_max(x,y,z): #函数的嵌套调用 # c = max(x,y) # return ...

  4. 1,Python常用库之一:Numpy

    Numpy支持大量的维度数组和矩阵运算,对数组运算提供了大量的数学函数库! Numpy比Python列表更具优势,其中一个优势便是速度.在对大型数组执行操作时,Numpy的速度比Python列表的速度 ...

  5. android onNewIntent 为什么要在onNewIntent的时候要显示的去调用setIntent

    原因: 当调用到onNewIntent(intent)的时候,需要在onNewIntent() 中使用setIntent(intent)赋值给Activity的Intent.否则,后续的getInte ...

  6. oracle(sql)基础篇系列(二)——多表连接查询、子查询、视图

    多表连接查询 内连接(inner join) 目的:将多张表中能通过链接谓词或者链接运算符连接起来的数据查询出来. 等值连接(join...on(...=...)) --选出雇员的名字和雇员所在的部门 ...

  7. videomon 环境搭建

    1.安装ACE-5.8.0.tar.bz2 tar -zxvf ACE-.tar.bz2 cd ACE_wrappers/mkdir buildcd build../configuremake &am ...

  8. 2.ifconfig

    转载http://www.cnblogs.com/peida/archive/2013/02/27/2934525.html 许多windows非常熟悉ipconfig命令行工具,它被用来获取网络接口 ...

  9. Win10开始菜单中的天气不更新问题的解决方法

    两台电脑同时做的Win10系统,最新的1703 Creator Update 版本,其中一台的开始菜单中天气方块总是显示图标,试了各种方法都不行,最后是点开天气App,在App的顶端有几个按钮,其中有 ...

  10. 剑指Offer - 九度1524 - 复杂链表的复制

    剑指Offer - 九度1524 - 复杂链表的复制2014-02-07 01:30 题目描述: 输入一个复杂链表(每个节点中有节点值,以及两个指针,一个指向下一个节点,另一个特殊指针指向任意一个节点 ...