[ 문제 ]
과거 이집트인들은 각 변들의 길이가 3, 4, 5인 삼각형이 직각 삼각형인것을 알아냈다.
주어진 세변의 길이로 삼각형이 직각인지 아닌지 구분하시오.
[ 입력 ]
- 입력은 여러개의 테스트케이스로 주어지며 마지막줄에는 0 0 0이 입력된다.
- 각 테스트케이스는 모두 30,000보다 작은 양의 정수로 주어지며, 각 입력은 변의 길이를 의미한다.
[ 출력 ]
- 각 입력에 대해 직각 삼각형이 맞다면 "right", 아니라면 "wrong"을 출력한다.
[ 예제 입력 ]
6 8 10
25 52 60
5 12 13
0 0 0
[ 예제 출력 ]
right
wrong
right
import java.util.*;
import java.io.*;
public class Main {
public static void main (String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
while (true) {
String s = br.readLine();
if (s.equals("0 0 0")) break;
StringTokenizer st = new StringTokenizer(s);
int[] nums = new int[3];
for (int i = 0; i < 3; i++)
nums[i] = Integer.parseInt(st.nextToken());
Arrays.sort(nums);
if (Math.pow(nums[2], 2) == Math.pow(nums[0], 2) + Math.pow(nums[1], 2))
System.out.println("right");
else
System.out.println("wrong");
}
}
}
'Algorithm > 백준+프로그래머스+SWEA+정올+구름' 카테고리의 다른 글
[Algorithm] 백준 1978 소수 찾기 (0) | 2021.08.16 |
---|---|
[Algorithm] 백준 11653 소인수분해 (0) | 2021.08.16 |
[Algorithm] 백준 11047 동전 0 (0) | 2021.08.15 |
[Algorithm] 백준 11399 ATM (0) | 2021.08.15 |
[Algorithm] 백준 15686 치킨 배달 (0) | 2021.08.15 |