zoukankan      html  css  js  c++  java
  • URAL 1942 Attack at the Orbit

    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

    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<stdio.h>
    #include<string.h>
    #include<iostream>
    #include<math.h>
    #include<algorithm>
    
    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",&n)!=EOF){
                memset(sum,0,sizeof(sum));
            double x,y;
            for(int i=1;i<=n;i++){
                scanf("%lf%lf",&x,&y);
                int tx=(int)(round(x*1000))%1000;
                int ty=(int)(round(y*1000))%1000;
                if(tx<0)
                    tx+=1000;
                if(ty<0)
                    ty+=1000;
                sum[tx][ty]++;
            }
            int ans1=0,ans2=999999999;
            for(int i=0;i<=1000;i++){
                for(int j=0;j<=1000;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
    ",ans1,sqrt(ans2*esp));
    
        }
        return 0;
    }
  • 相关阅读:
    004-核心技术-netty概述、传统IO、Reactor线程模型
    003-核心技术-IO模型-NIO-基于NIO群聊示例
    002-核心技术-IO模型-NIO【Selector、Channel、Buffer】、零拷贝
    018-redis-命令合计
    【整理】js、python、java分别对url进行编码和解码
    深度 | 翟东升:写在美帝国撤军和阿富汗政权溃散之际
    修改Windows10 命令终端cmd的编码为UTF-8 && IDEA控制台输出中文乱码
    Dockerfile文件中的ENTRYPOINT,CMD命令跟k8s中command,args之间的关系
    服务器带宽,流量之间的关系
    值得收藏的下载地址
  • 原文地址:https://www.cnblogs.com/13224ACMer/p/4688089.html
Copyright © 2011-2022 走看看