zoukankan      html  css  js  c++  java
  • Quoit Design

    Quoit Design

    Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
    Total Submission(s): 46340    Accepted Submission(s): 12084

    这题可以分治:

    首先按照x方向排序,然后分别对 两边求最短距离。

    然后按照y排序,统计距离分割点-d 和+d之间的点,算了,忘了。

    但是可以直接排序,然后枚举相邻三个点之间到距离。这三个点的组合总计三个距离,可以证明最短到距离一定存在于某个

    三元组里。

    Problem Description
    Have you ever played quoit in a playground? Quoit is a game in which flat rings are pitched at some toys, with all the toys encircled awarded.
    In the field of Cyberground, the position of each toy is fixed, and the ring is carefully designed so it can only encircle one toy at a time. On the other hand, to make the game look more attractive, the ring is designed to have the largest radius. Given a configuration of the field, you are supposed to find the radius of such a ring.

    Assume that all the toys are points on a plane. A point is encircled by the ring if the distance between the point and the center of the ring is strictly less than the radius of the ring. If two toys are placed at the same point, the radius of the ring is considered to be 0.
     
    Input
    The input consists of several test cases. For each case, the first line contains an integer N (2 <= N <= 100,000), the total number of toys in the field. Then N lines follow, each contains a pair of (x, y) which are the coordinates of a toy. The input is terminated by N = 0.
     
    Output
    For each test case, print in one line the radius of the ring required by the Cyberground manager, accurate up to 2 decimal places. 
     
    Sample Input
    2 0 0 1 1 2 1 1 1 1 3 -1.5 0 0 0 0 1.5 0
     
    Sample Output
    0.71 0.00 0.75
     
    Author
    CHEN, Yue
     
    Source
     
    Recommend
    JGShining
     
    #include<iostream>
    #include<stdio.h>
    #include<algorithm>
    #include<math.h>
    using namespace std;
    const int maxx=100005;
    struct Node{
        double x;
        double y;
    }node[maxx];
    bool cmp(Node a,Node b){
        if(a.x!=b.x) return a.x<b.x;
        return a.y<b.y;
    }
    double dis(Node a,Node b){
        double dx,dy;
        dx=a.x-b.x;
        dy=a.y-b.y;
        double ans=dx*dx+dy*dy;
        return sqrt(ans);
    }
    double min(double a,double b,double c){
    
        double tmp=0.0;
        tmp=(a<=b)?a:b;
        tmp= (tmp<=c)?tmp:c;
        //cout<<a<<"  "<<b<<" "<<c<<"  "<<tmp<<endl;
        return tmp;
    }
    int main(){
            
        int n;
        while(scanf("%d",&n)&&n!=0){
    
            for(int i=0;i<n;i++){
                scanf("%lf%lf",&node[i].x,&node[i].y);
            }
            sort(node,node+n,cmp);
            double ans=1000000.0;
            if(n==1){
                printf("0.00
    ");
                continue;
            }else if(n==2){
                printf("%.2lf
    ",dis(node[0],node[1])/2);
                continue;
            }
            double tmp;
            for(int i=1;i<n-1;i++){
                tmp=min(dis(node[i-1],node[i]),dis(node[i],node[i+1]),dis(node[i-1],node[i+1]));
                ans=min(ans,tmp);
            }
            ans=ans/2;
            printf("%.2lf
    ",ans);
        }
        return 0;
    }
    View Code
  • 相关阅读:
    redhat linux 5.6 下安装oracle 11g 时netca报错不能配置监听解决方法
    数据库迁移windows>linux ORACLE 10G
    RedHat Linux 5.3 下安装ORACLE 软件之后手动安装数据库脚本记录
    X Server/Client
    Oracle实例解析:编码与字符集(转)
    RedHat Linux 5.3 下安装ORACLE DATABASE 10G
    Toad 10.5 连接RedHat Linux 5.3 下Oracle 10g
    RedHat5.6 安装mysql
    oracle 数据库开发原则(转自求道的路上)
    第一篇使用windows live writer发布日志
  • 原文地址:https://www.cnblogs.com/superxuezhazha/p/5693071.html
Copyright © 2011-2022 走看看