-
4153번 : 직각삼각형Programming/백준 2021. 5. 5. 09:38
#include <iostream> #include <cmath> bool Predicate(const int x, const int y, const int r) { int pred1 = std::max(x, y); int max = std::max(pred1, r); if (max == pred1) { if (pred1 == x) { return (x * x == ((y * y) + (r * r))); } else { return (y * y == ((x * x) + (r * r))); } } else { return (r * r == ((x * x) + (y * y))); } } int main(void) { std::cin.tie(NULL); std::cout.tie(NULL); std::cin.sync_with_stdio(false); int x, y, r; while (true) { std::cin >> x >> y >> r; if (x == 0 && y == 0 && r == 0) break; std::cout << (Predicate(x, y, r) ? "right" : "wrong") << "\n"; } return 0; }
4153번: 직각삼각형
입력은 여러개의 테스트케이스로 주어지며 마지막줄에는 0 0 0이 입력된다. 각 테스트케이스는 모두 30,000보다 작은 양의 정수로 주어지며, 각 입력은 변의 길이를 의미한다.
www.acmicpc.net
'Programming > 백준' 카테고리의 다른 글
10870번 : 피보나치 수 5 (0) 2021.05.05 10872번 : 팩토리얼 (0) 2021.05.05 3009 : 네 번째 점 (0) 2021.05.05 1085번 : 직사각형에서 탈출 (0) 2021.05.03 9020 : 골드바흐의 추측 (0) 2021.05.02