博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hdu 4386Quadrilateral
阅读量:5207 次
发布时间:2019-06-14

本文共 1920 字,大约阅读时间需要 6 分钟。

Quadrilateral

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 937    Accepted Submission(s): 421

Problem Description
  One day the little Jack is playing a game with four crabsticks. The game is simple, he want to make all the four crabsticks to be a quadrilateral, which has the biggest area in all the possible ways. But Jack’s math is so bad, he doesn’t know how to do it, can you help him using your excellent programming skills?
 

 

Input
  The first line contains an integer N (1 <= N <= 10000) which indicates the number of test cases. The next N lines contain 4 integers a, b, c, d, indicating the length of the crabsticks.(1 <= a, b, c, d <= 1000)
 

 

Output
  For each test case, please output a line “Case X: Y”. X indicating the number of test cases, and Y indicating the area of the quadrilateral Jack want to make. Accurate to 6 digits after the decimal point. If there is no such quadrilateral, print “-1” instead.
 

 

Sample Input
2 1 1 1 1 1 2 3 4
 

 

Sample Output
Case 1: 1.000000 Case 2: 4.898979
 

 

Author
WHU
 
四边形不稳定,给定四边后不能确定面积。面积最大的是圆内接四边形,设四边长为abcd,半周长为p,则最大面积=sqrt((p-a)*(p-b)*(p-c)*(p-d))。。忘了怎么证明去了。
View Code
1 #include 
2 #include
3 #include
4 int main() 5 { 6 int t; 7 int a,b,c,d,max,count=0; 8 double p,ans; 9 scanf("%d",&t);10 while(t--)11 {12 scanf("%d%d%d%d",&a,&b,&c,&d);13 if(a>b) max=a;14 else max=b;15 if(max
=0)19 {20 printf("Case %d: -1\n",++count);21 continue;22 }23 p=(a+b+c+d)*1.0/2;24 ans=sqrt((p-a)*(p-b)*(p-c)*(p-d));25 printf("Case %d: %.6lf\n",++count,ans);26 27 28 }29 }

 

转载于:https://www.cnblogs.com/1114250779boke/archive/2012/11/09/2763205.html

你可能感兴趣的文章
oauth2学习
查看>>
Python time & datetime & string 相互转换
查看>>
细说WebSocket - Node篇
查看>>
【pwnable.kr】 flag
查看>>
1014 装箱问题——http://codevs.cn/problem/1014/
查看>>
poj 3177 边双联通 **
查看>>
java.lang.UnsupportedOperationException
查看>>
java-斐波那契数列的解法
查看>>
rackup工具
查看>>
Linux operating system (Ubuntu) 学习-1
查看>>
ajax-原生写法步骤
查看>>
.Net语言 APP开发平台——Smobiler学习日志:如何在手机上实现饼图图表
查看>>
svn完整备份迁移
查看>>
Python字典实现分析
查看>>
jenkins+testNG
查看>>
Java自定义范型的应用技巧
查看>>
[洛谷1485] 火枪打怪
查看>>
白话经典算法系列之六 快速排序 快速搞定
查看>>
错了:用流量能够放肆,有wifi则要节制
查看>>
CSS渐变字体、镂空字体、input框提示信息颜色、给图片加上内阴影、3/4圆
查看>>