地大邀请赛d
Problem D: Tetrahedron Inequality
Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 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
Sample Output
#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的更多相关文章
- 2013ACM暑假集训总结-致将走上大三征途的我
回想起这个暑假,从开始与雄鹰一起的纠结要不要进集训队,与吉吉博博组队参加地大邀请赛,害怕进不了集训队.当时激励我月份开始接触的,记得当时在弄运动会来着,然后就问了雄鹰一些输入输出的东西,怀着满心的期待 ...
- 1250 Super Fast Fourier Transform(湘潭邀请赛 暴力 思维)
湘潭邀请赛的一题,名字叫"超级FFT"最终暴力就行,还是思维不够灵活,要吸取教训. 由于每组数据总量只有1e5这个级别,和不超过1e6,故先预处理再暴力即可. #include&l ...
- 2014嘉杰信息杯ACM/ICPC湖南程序设计邀请赛暨第六届湘潭市程序设计竞赛
比赛链接: http://202.197.224.59/OnlineJudge2/index.php/Contest/problems/contest_id/36 题目来源: 2014嘉杰信息杯ACM ...
- 湘潭邀请赛 Hamiltonian Path
湘潭邀请赛的C题,哈密顿路径,边为有向且给定的所有边起点小于终点,怎么感觉是脑筋急转弯? 以后一定要牢记思维活跃一点,把复杂的事情尽量简单化而不是简单的事情复杂化. #include<cstdi ...
- 2014 ACM/ICPC 北京邀请赛 部分 题解
题目链接:http://acm.bnu.edu.cn/bnuoj/problem.php?search=2014+ACM-ICPC+Beijing+Invitational+Programming+C ...
- 中南大学第一届长沙地区程序设计邀请赛 New Sorting Algorithm
1352: New Sorting Algorithm Time Limit: 1 Sec Memory Limit: 128 MB Description We are trying to use ...
- 中南大学第一届长沙地区程序设计邀请赛 To Add Which?
1350: To Add Which? Time Limit: 1 Sec Memory Limit: 128 MB Description There is an integer sequence ...
- 2013 ACM/ICPC南京邀请赛B题(求割点扩展)
题目链接:http://icpc.njust.edu.cn/Contest/194/Problem/B B - TWO NODES 时间限制: 10000 MS 内存限制: 65535 KB 问题描述 ...
- hihocoder 1084 扩展KMP && 2014 北京邀请赛 Justice String
hihocoder 1084 : http://hihocoder.com/problemset/problem/1084 北京邀请赛 Just String http://www.bnuoj.co ...
随机推荐
- Reverse Words in a String | LeetCode OJ | C++
我的思路:先读取每一个单词,存放到容器中:读取完毕后,将容器中的单词倒序写入输出中. #include<iostream> #include<string> #include& ...
- SED修改指定行
一个文件:cat aa #如果第三行是5的话将改为8,很明显第三行是5所以 结果改变 [root@remote ~]# sed -e '3s/5/8/' aa [root@remote ~]# #如果 ...
- SQL -主键&外键
在创建表的时候,添加主键 CREATE TABLE table_name (column_1 char(10) PRIMARY KEY, column_2 char(10) ) 如果已经创建了表,如何 ...
- Cloud Engine
Cloud Engine:大杀器如何炼成 郑昀 创建于2016/6/18 最后更新于2016/6/19 点击查看我的<如何从零搭建一个技术平台>,这是一个系列.转载时请注明“转载自旁观 ...
- boost 分析命令行参数
#include <boost/program_options.hpp> #include <iostream> #include <vector> using n ...
- Android开发10.1:UI组件适配器AdapterView(创建ListView,Adapter接口)
@version:Android4.3 API18 @author:liuxinming 概述 AdapterView继承了ViewGroup,它的本质是容器 ...
- 在前端页面中使用@font-face来显示web自定义字体【转】
本文转自W3CPLUS 的<CSS @font-face> @font-face是CSS3中的一个模块,他主要是把自己定义的Web字体嵌入到你的网页中,随着@font-face模块的出现, ...
- AsyncTask的用法总结
这几天被AsyncTask虐得不行,在此总结下 首先: AsyncTask的参数介绍 在开发Android移动客户端的时候往往要使用多线程来进行操作,我们通常会将耗时的操作放在单独的线程执行,避免其占 ...
- Linux下安装配置词典GoldenDict
GoldenDict apt-get install goldendict 安装完成以后,需要自己手动加入字典,增加在线翻译网址(例如,有道,金山等),点击 编辑--dictionaries 完 ...
- 使用C语言实现字符串中子字符串的替换
描述:编写一个字符串替换函数,如函数名为 StrReplace(char* strSrc, char* strFind, char* strReplace),strSrc为原字符串,strFind是待 ...