Question: http://acm.zju.edu.cn/onlinejudge/showProblem.do? Problemcode = 3716.
Source: http://acm.hust.edu.cn/vjudge/contest/view.action? Cid = 26644 # Problem/
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 shoshould 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 shoshould avoid this. four distinct points will be givenXi YiBefore
The competition begins. Players shoshould 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 shocould 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 integersXI(-10 ^ 8 ≤XI≤ 10 ^ 8) andYi(-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 00 34 04 3
Sample output
6.00000000
Author: Yang, jueji
Contest: zoj monthly, Jun 2013
Here are four points for you. Four people dance the ribbons at four points. Each ribbon cannot meet each other. Ask for the maximum length of the four.
Idea: when starting the competition, I want to draw the circle from these four points to find the four circles as tangent as possible, and to find the biggest radius and sum.
First, find the shortest line in the two vertices, and then determine the two tangent circles, and then move up and down to slowly determine the other circles.
I never thought of how to determine, but I gave up later...
Just found the problem solution, it should be a positive solution, is also the circle tangent of the http://blog.csdn.net/u010638776/article/details/9218995
I just asked kb, and he gave me the idea of a legendary world champion yy.
The second passed quickly. The great god of Knowledge gave me a proof of orz.
A |
Accepted |
180 KB |
MS 0 |
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\n", ans); } return 0;}