Volume0: 0003
三平方の定理を利用します
直角三角形の斜辺 と他の 辺 との関係は、 です
C++
#include <iostream> using namespace std; int a, b, c, n; int main() { cin >> n; for (int i = 0; i < n; ++i) { cin >> a >> b >> c; // cを斜辺にする if (a > c) swap(a, c); if (b > c) swap(b, c); cout << (a * a + b * b == c * c ? "YES" : "NO") << endl; } return 0; }
Python
# coding: utf-8 for i in range(int(input())): a, b, c = sorted([int(i) for i in input().split()]) print('YES' if a ** 2 + b ** 2 == c ** 2 else 'NO')
Ruby
# coding: utf-8 gets.to_i.times do a, b, c = gets.chomp.split().map(&:to_i).sort() puts a ** 2 + b ** 2 == c ** 2 ? 'YES' : 'NO' end