hdu 2393 Higher Math

题意:输入三个数字,判断是否可以构成直角三角形。

公式: a * a + b * b = c * c;

注意:c++的输出,字符串最好不要与数字连用,不然输出的字符会少一些。

1输入的数据不是有序的要判断哪个是斜边才行,我直接套用公式简单方便。

#include<iostream>
using namespace std;

int main(){
    int n,a,b,c;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a>>b>>c;
        cout<<"Scenario #"<<i<<":"<<endl;
        if(a*a+b*b==c*c){
            cout<<"yes"<<endl<<endl;
        }else if(a*a+c*c==b*b){
            cout<<"yes"<<endl<<endl;
        }else if(c*c+b*b==a*a){
            cout<<"yes"<<endl<<endl;
        }else{
            cout<<"no"<<endl<<endl;
        }
    }
    return 0;
}



Higher Math

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2752    Accepted Submission(s): 1481


Problem Description
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, 
所有你需要做的是,靠近墙面,然后走几步,测量你走的距离(低width),
measure the height of the wall, and the distance from the upper edge of the wall to where you stand. 
测量墙的高度(高height)和墙的上边缘到与你你站的地方的距离(斜边hypotenuse)。
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.
 给定一个三角形的三条边,如果一个三角形的角度是90度,确定是否可以组成一个直角三角形。

Input
The inputs start with a line containing a single integer n. 
输入的起始行包含一个整数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. 
每个测试用例包括三个整数1 < = a,b,c < = 40000之间用一个空格来分隔。
The three integers are the lengths of the sides of a triangle.
 三个整数的长度表示一个三角形的三条边。

Output
The output for every scenario begins with a line containing “Scenario #i:”, where i is the number of the scenario counting from 1. 
对于每一个输出方案,都要输出“Scenario #i:”的格式,i是序列号。
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. 
在判断数据之后,在一个单独的行输出字符串“yes”或字符串“no”。
Terminate each test case with an empty line.
每个测试用例都有一个空行。

Sample Input
  
  
2 36 77 85 40 55 69
 

Sample Output
  
  
Scenario #1: yes Scenario #2: no
 

Source

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值