HDU2393 Higher Math【几何】【水题】

来源:互联网 发布:宁波网络继续教育 编辑:程序博客网 时间:2024/05/24 16:16

题目链接:

http://acm.hdu.edu.cn/showproblem.php?pid=2393


题目大意:

给你三角形的三条边长,问:是否能构成直角三角形。


思路:

三角形勾股定理。最大边不超过40000,运算中间数最大是3.2*10^9,int的上界是2.2*10^10,

所以不用担心溢出。


AC代码:

#include<iostream>#include<algorithm>#include<cstdio>#include<cstring>#include<cmath>using namespace std;int main(){    int T,a,b,c,kase = 0;    cin >> T;    while(T--)    {        cin >> a >> b >> c;        cout << "Scenario #" << ++kase << ':' << endl;        if(a*a+b*b==c*c || a*a+c*c==b*b || b*b+c*c==a*a)            cout << "yes" << endl;        else            cout << "no" << endl;        cout << endl;    }        return 0;}


0 0
原创粉丝点击