zoj 3716 Ribbon Gymnastics【神奇的计算几何】

24 篇文章 0 订阅
12 篇文章 0 订阅

题目: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

AAccepted180 KB0 msC++ (g++ 4.4.5)729 B2013-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\n", ans);
    }
    return 0;
}


评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值