地大邀请赛d
2013-07-15 21:11
309 查看
Problem D: Tetrahedron Inequality
Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 15
Solved: 3
[
Submit][
Status][
Web Board]
Description
It is well known that you cannot make a triangle with non-zero area whose sides have lengths 1, 2, 3. Can you make a tetrahedron(四面体) with non-zero volume whose edges have lengths 1, 2, 3, 4, 5, 6?Input
The first line of input contains an integer 0 < n <= 10000, the number of lines to follow. Each of the next n lines contains six positive integers separated by spaces, the lengths of the edges of the desired tetrahedron. The length of each edge is no greater than 1000000.Output
Output n lines, each containing the word YES if it is possible to construct a tetrahedron with non-zero volume with the given edge lengths, or the word NO if it is not possible.Sample Input
21 2 3 4 5 610 10 10 10 10 18Sample Output
NONO队友所写,之后,为这题不知争了多少次,调了不知道多长时间,怎么测都对,提交就是不对,最后原来这题
还是那个精度问题,因为,有可能是1000000,这样肯定,越界了的,所以必须太大的时候,除个1000才行,警记
#include<stdio.h> #include<math.h> int judge(double a,double b,double c) //判定能否组成三角形 { if(a+b>c&&a+c>b&&b+c>a) return 1; else return 0; } int cal(double a,double b,double c,double d,double e,double f) { if(a>1000) { a/=1000.0; b/=1000.0; c/=1000.0; d/=1000.0; e/=1000.0; f/=1000.0; } double L1,L2,h1,h2,x1,x2,ff; L1=(a+b+d)/2.0; L2=(a+c+e)/2.0; h1=2*sqrt(L1)*sqrt(L1-a)/a*sqrt(L1-b)*sqrt(L1-d);// h2=2*sqrt(L2)*sqrt(L2-a)/a*sqrt(L2-c)*sqrt(L2-e); x1=(b*b+e*e-d*d-c*c)/4/a/a*(b*b+e*e-d*d-c*c);//是平方过的, //x2=(b*b+e*e-d*d-c*c)*(b*b+e*e-d*d-c*c)/4/a/a; ff=f*f; if(ff<(h1+h2)*(h1+h2)+x1&&ff>(h1-h2)*(h1-h2)+x1) return 1; else return 0; } int main() { int t,a,b,c,d,e,f,i,j; double r[6]; scanf("%d",&t); while(t--) { for(i=0;i<6;i++) scanf("%lf",&r[i]); for(j=0,a=0;a<5;a++) { for(b=0;b<5;b++) { if(a!=b) for(c=0;c<5;c++) {if(a!=c&&b!=c) for(d=0;d<5;d++) {if(a!=d&&d!=c&&b!=d&&judge(r[a],r[b],r[d])) for(e=0;e<5;e++) {if(a!=e&&d!=e&&b!=e&&c!=e) if(judge(r[a],r[c],r[e])) { if(cal(r[a],r[b],r[c],r[d],r[e],r[5])) { j++; break; } } if(j) break; } if(j) break; } if(j) break; } if(j) break; } if(j) break; } if(j) printf("YES\n"); else printf("NO\n"); } return 0; }
相关文章推荐
- 地大邀请赛d
- 080510杭电邀请赛
- 阿里巴巴杯与武大第六届中部地区邀请赛的其中几题
- google杯邀请赛 Avaricious Maryanna
- ACM-ICPC全国邀请赛,长春
- POJ 4045 Power Station 2012金华邀请赛B题(树形DP)
- 金华邀请赛 G - Necklace 限制polya 这两份代码到底什么意思?
- WHU1478----2014年武大邀请赛H题----双向链表
- A - Play the Dice (2013南京邀请赛A题)
- 2013 通化邀请赛小记
- Hdu 4571Travel in time2013长沙邀请赛
- 【正畸病例PK邀请赛】计分规则收录及界面设计图
- 2013 杭州区邀请赛 Building bridges
- HDUOJ 4578 2013杭州邀请赛重现 Transformation
- 8#10 - 杭州邀请赛 重现
- 8#17 - 南京邀请赛
- 2013 ACM-ICPC吉林通化全国邀请赛——题目重现
- HDU 4496 Tutor 2013 ACM-ICPC吉林通化全国邀请赛E题
- 13成都邀请赛 1007 Good Numbers
- Hdu 4568 Hunter 2013长沙邀请赛