zoukankan      html  css  js  c++  java
  • zoj 3716 Ribbon Gymnastics【神奇的计算几何】

    题目:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3716

    来源:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=26644#problem/A

    Ribbon Gymnastics

    Time Limit: 2 Seconds      Memory Limit: 65536 KB      Special Judge

    Robert is a gymnastics coach. Unfortunately, he got four gymnastics beginners to attend the coming competition. Since the competition has a nice award, Robert will make all his effort to win the competition.

    One performance requires that each of the four player should take a ribbon and rotate herself, and assume the ribbons will then straighten out. Since Robert's four players are beginners, Robert cannot control the actual rotating speeds of four players during the competition. And when two ribbons touch, they may wind, which will cause players felling down. For safety, Robert should avoid this. Four distinct points will be given as xi yi before the competition begins. Players should stand at those points when rotating.

    The longer the ribbons are, the more bonus Robert will gain. After knowing the four points Robert can choose ribbons and points for each player. The length of each ribbon should be positive. So help Robert to find the maximal total lengths of the four ribbons.

    Input

    There will be multiple test cases.Please process to the end of input.

    Each test case contains four lines.

    Each line contains two integers xi (-10^8≤xi≤10^8) and yi (-10^8≤yi≤10^8).

    Output

    Output the total maximal sum of the lengths of the four ribbons. Answer having an absolute or relative error less than 1e-6 will be accepted.

    Sample Input

    0 0
    0 3
    4 0
    4 3
    

    Sample Output

    6.00000000
    

    Author: YANG, Jueji
    Contest: ZOJ Monthly, June 2013


    题意:给你四个点,四个人在四个点上舞动丝带,各条丝带不能相遇,求四人最大的丝带总长度。

    思路:开始比赛时想的是以这四个点画圆求四个圆尽量相切,求最大的半径和。

       先找出两两点中的最短的一条线,由此必然确定了两个相切的圆,然后再上下移动,慢慢的确定另外的圆。

              一直没想到怎么确定,后来就放弃了。。。

             刚刚搜了下题解,应该这个是正解,也是圆相切的http://blog.csdn.net/u010638776/article/details/9218995

    刚刚问了下KB神,他给了个传说中世界冠军 YY的思路

    迅速秒过啊,求知道的大神给个证明Orz

    A Accepted 180 KB 0 ms C++ (g++ 4.4.5) 729 B 2013-07-20 17:27:52

    #include<stdio.h>
    #include<math.h>
    #include<algorithm>
    using namespace std;
    
    struct Point{
        double x;
        double y;
    }p[5];
    
    double dist(Point a, Point b)
    {
        return sqrt((a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y));
    }
    
    int main()
    {
        while(scanf("%lf%lf", &p[0].x, &p[0].y) != EOF)
        {
            for(int i = 1; i < 4; i++)
            {
                scanf("%lf%lf", &p[i].x, &p[i].y);
            }
            double d1 = dist(p[0], p[1]);
            double d2 = dist(p[1], p[2]);
            double d3 = dist(p[2], p[3]);
            double d4 = dist(p[0], p[3]);
            double d5 = dist(p[0], p[2]);
            double d6 = dist(p[1], p[3]);
    
            double ans = min(d1+d3, min(d4+d2, d5+d6));
            printf("%.8lf
    ", ans);
        }
        return 0;
    }
    


  • 相关阅读:
    Kotlin开发 扩展函数在Android开发中的一些实用例子
    Kotlin开发 使用lambda实现接口回调
    Android开发 Camera2的CaptureRequest属性整理--完善中
    Android开发 Bitmap图像处理详解
    Android开发 Camera预览画面镜像问题
    Android开发 ViewPage2
    windows 服务器更新程序下载-修复漏洞
    JAVA实现数据等分,一个List分成多个List
    List<CourseRecord>转HashMap<Long, List<CourseRecord>>
    模拟服务器1.0——WebServer 、ClientHandler 接收请求、做出响应
  • 原文地址:https://www.cnblogs.com/freezhan/p/3219092.html
Copyright © 2011-2022 走看看