POJ1927 Area in Triangle

 
Time Limit: 1000MS   Memory Limit: 30000K
Total Submissions: 1458   Accepted: 759

Description

Given a triangle field and a rope of a certain length (Figure-1), you are required to use the rope to enclose a region within the field and make the region as large as possible. 

Input

The input has several sets of test data. Each set is one line containing four numbers separated by a space. The first three indicate the lengths of the edges of the triangle field, and the fourth is the length of the rope. Each of the four numbers have exactly four digits after the decimal point. The line containing four zeros ends the input and should not be processed. You can assume each of the edges are not longer than 100.0000 and the length of the rope is not longer than the perimeter of the field.

Output

Output one line for each case in the following format: 

Case i: X 

Where i is the case number, and X is the largest area which is rounded to two digits after the decimal point. 

Sample Input

12.0000 23.0000 17.0000 40.0000
84.0000 35.0000 91.0000 210.0000
100.0000 100.0000 100.0000 181.3800
0 0 0 0

Sample Output

Case 1: 89.35
Case 2: 1470.00
Case 3: 2618.00

Source

 

数学问题 计算几何

(物理题?)

画图太麻烦了,随便贴个别处的题解吧233 http://blog.csdn.net/xuechelingxiao/article/details/40707691

没加case傻傻WA了两次

 1 /*by SilverN*/
 2 #include<algorithm>
 3 #include<iostream>
 4 #include<cstring>
 5 #include<cstdio>
 6 #include<cmath>
 7 #include<vector>
 8 using namespace std;
 9 const int mxn=100010;
10 int read(){
11     int x=0,f=1;char ch=getchar();
12     while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
13     while(ch>='0' && ch<='9'){x=x*10+ch-'0';ch=getchar();}
14     return x*f;
15 }
16 double a,b,c,d;
17 inline double Sin(double a,double b,double c){
18     double Cos=(a*a+b*b-c*c)/(2*a*b);
19     return sqrt(1-Cos*Cos);
20 }
21 double calc(double a,double b,double c,double d){
22     double Pi=acos(-1.0);
23     double S=0.5*a*b*Sin(a,b,c);
24     if(d-(a+b+c)>=0){return S;}
25     double h=S*2/(a+b+c);
26     if(h*2*Pi>=d){return d*d/4/Pi;}
27     double Len=a+b+c;
28     double T=(Len-d)/(Len-2*Pi*h);
29     return S-S*T*T+(h*T)*(h*T)*Pi;
30 }
31 int main(){
32     int i,j,cas=0;
33     while(scanf("%lf%lf%lf%lf",&a,&b,&c,&d)!=EOF){
34         if(a==0 && b==0 && c==0 && d==0)break;
35         printf("Case %d: %.2f\n",++cas,calc(a,b,c,d));
36     }
37     return 0;
38 }

 

posted @ 2017-02-28 20:48  SilverNebula  阅读(150)  评论(0编辑  收藏  举报
AmazingCounters.com