読者です 読者をやめる 読者になる 読者になる

300億円欲しい

メジャーリーグのデータ解析します

AOJ 0003

初心者のC++

問題

Is it a Right Triangle?

Write a program which judges wheather given length of three side form a right triangle. Print "YES" if the given sides (integers) form a right triangle, "NO" if not so.

Input

Input consists of several data sets. In the first line, the number of data set, N is given. Then, N lines follow, each line corresponds to a data set. A data set consists of three integers separated by a single space.

Constraints

1 ≤ length of the side ≤ 1000
N ≤ 1000

Output

For each data set, print "YES" or "NO".

http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0003

解答

#include<iostream>
#include<algorithm>
using namespace std;

int main(){
    int a[3];
    int b;
    cin >> b;
    while(cin >> a[0] >> a[1] >> a[2]){
        sort(a,a+3);
        if(a[2]*a[2] == a[1]*a[1] + a[0]*a[0]){
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
    return 0;
}

while(cin >> a[0] >> a[1] >> a[2]) という書き方が便利ですねよく分からんけど