백준 4153번(Java)

박은지·2025년 2월 3일

백준

목록 보기
1/89
post-thumbnail


단순히 직각삼각형의 공식을 사용해서 문제 해결

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));
        
        StringBuilder sb = new StringBuilder();
       
 
        while(true) {
        	StringTokenizer st = new StringTokenizer(br.readLine()," ");
            
        	int x = Integer.parseInt(st.nextToken());
        	int y = Integer.parseInt(st.nextToken());
        	int z = Integer.parseInt(st.nextToken());
        	
        	if(x == 0 && y == 0 && z == 0) break;
            
        	
        	if((x * x + y * y) == z * z) {
				sb.append("right").append('\n');
			}
        	else if(x * x == (y * y + z * z)) {
				sb.append("right").append('\n');
			}
        	else if(y * y == (z * z + x * x)) {
				sb.append("right").append('\n');
			}
        	else {
				sb.append("wrong").append('\n');
			}
        	
		}
		System.out.println(sb);
	}
 
}
profile
백엔드 개발자가 되고싶은 eunzi😊

0개의 댓글