hdu2393Higher Math
2015-06-06 18:20
316 查看
[align=left]Problem Description[/align]
You are building a house. You’d prefer if all the walls have a precise right angle relative to the ground, but you have no device to measure angles. A friend says he has a great idea how you could ensure that all walls are upright: All you need to do is step away a few feet from the wall, measure how far away you are from the wall, measure the height of the wall, and the distance from the upper edge of the wall to where you stand. You friend tells you to do these measurements for all walls, then he’ll tell you how to proceed. Sadly, just as you are done, a timber falls on your friend, and an ambulance brings him to the hospital. This is too bad, because now you have to figure out what to do with your measurements yourself.
Given the three sides of a triangle, determine if the triangle is a right triangle, i.e. if one of the triangle’s angles is 90 degrees.
[align=left]Input[/align]
The inputs start with a line containing a single integer n. Each of the n following lines contains one test case. Each test case consists of three integers 1 <= a, b, c <= 40000 separated by a space. The three integers are the lengths of the sides of a triangle.
[align=left]Output[/align]
The output for every scenario begins with a line containing “Scenario #i:”, where i is the number of the scenario counting from 1. After that, output a single line containing either the string “yes” or the string “no”, depending on if the triangle in this test case has a right angle. Terminate each test case with an empty line.
[align=left]Sample Input[/align]
2
36 77 85
40 55 69
[align=left]Sample Output[/align]
Scenario #1:
yes
Scenario #2:
no
[align=left]Source[/align]
HDU 2008-10 Public Contest
You are building a house. You’d prefer if all the walls have a precise right angle relative to the ground, but you have no device to measure angles. A friend says he has a great idea how you could ensure that all walls are upright: All you need to do is step away a few feet from the wall, measure how far away you are from the wall, measure the height of the wall, and the distance from the upper edge of the wall to where you stand. You friend tells you to do these measurements for all walls, then he’ll tell you how to proceed. Sadly, just as you are done, a timber falls on your friend, and an ambulance brings him to the hospital. This is too bad, because now you have to figure out what to do with your measurements yourself.
Given the three sides of a triangle, determine if the triangle is a right triangle, i.e. if one of the triangle’s angles is 90 degrees.
[align=left]Input[/align]
The inputs start with a line containing a single integer n. Each of the n following lines contains one test case. Each test case consists of three integers 1 <= a, b, c <= 40000 separated by a space. The three integers are the lengths of the sides of a triangle.
[align=left]Output[/align]
The output for every scenario begins with a line containing “Scenario #i:”, where i is the number of the scenario counting from 1. After that, output a single line containing either the string “yes” or the string “no”, depending on if the triangle in this test case has a right angle. Terminate each test case with an empty line.
[align=left]Sample Input[/align]
2
36 77 85
40 55 69
[align=left]Sample Output[/align]
Scenario #1:
yes
Scenario #2:
no
[align=left]Source[/align]
HDU 2008-10 Public Contest
#include<iostream> #include<cstring> #include<cstdio> #include<cmath> using namespace std; int main() { int z,t = 0; cin>>z; while(z--) { printf("Scenario #%d:\n",++t); int a,b,c; cin>>a>>b>>c; if(a>b) swap(a,b); if(b>c) swap(b,c); if(a*a+b*b == c*c) cout<<"yes"<<endl<<endl; else cout<<"no"<<endl<<endl; } return 0; }
相关文章推荐
- 安装配置Jstorm集群
- EL表达式学习笔记
- 简单邮件传输协议
- 关于IP网段间互访的问题—路由是根本(转)
- 使用NGUI实现带有放大功能的scrollview背包
- 人生的意义是什么?
- MATLAB导入数据importdata功能
- 全套Oracle数据库安装实施视频课程套餐[涉及RAC,Linux,Win,ASM,Udev,FS]
- 抽象类使用规范的一些总结
- Hbase总结(五)-hbase常识及habse适合什么场景
- 我为什么要写博客?
- cygwin的坑坑洼洼
- Java层与Jni层的数组传递(转)
- uml精粹——10.状态机图
- golang grpc thrift with aerospike
- 汇编指令详细解释
- 银行家算法(Java语言实现)
- 图解如何 将Excel里的数据导入到sql server数据库中
- C实现 LeetCode->Longest Palindromic Substring
- Oracle RAC 11gR2+WebLogic集群6节点项目安装实施维护视频课程套餐