0523 코테 - 백준 4153번(직각삼각형)

한장민·2022년 5월 23일
0
post-thumbnail

백준 4153번

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		
		while(true) {
			StringTokenizer st = new StringTokenizer(br.readLine(), " ");
			int a = Integer.parseInt(st.nextToken());
			int b = Integer.parseInt(st.nextToken());
			int c = Integer.parseInt(st.nextToken());
			
			if(a == 0 && b == 0 && c == 0) break;
			
			if(	a*a == (b*b + c*c) ) {
				System.out.println("right");
			}else if((a*a + b*b) == c*c){
				System.out.println("right");
			}else if( b*b == (a*a + c*c)){
				System.out.println("right");
			}else {
				System.out.println("wrong");
			}
		}
	}
}

피타고라스의 법칙을 이용한 문제이다. 처음에 문제를 제대로 못보고 당연히 세 번째로 들어가는 정수가 대각변일 것이라 생각하여 오답이 나왔다. 문제를 잘 읽고 이해해야 할 것 같다.

profile
HAAN YJGB

0개의 댓글