본문 바로가기
백준/1 - 5000

[백준] 4562번 : No Brainer(JAVA)

by lms0806 2021. 7. 22.
728x90
반응형

https://www.acmicpc.net/problem/4562

 

4562번: No Brainer

For each data set, there will be exactly one line of output. This line will be "MMM BRAINS" if the number of brains the zombie eats is greater than or equal to the number of brains the zombie requires to stay alive. Otherwise, the line will be "NO BRAINS".

www.acmicpc.net

풀이

첫번째 입력받은 수가 두번째 입력받은 수보다 작으면 "NO BRAINS", 아니면 "MMM BRAINS"을 출력하면 되는 간단한 문제입니다.

 

소스코드

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)); 
		
		int size = Integer.parseInt(br.readLine());
		
		StringBuilder sb = new StringBuilder();
		while(size --> 0) {
			StringTokenizer st = new StringTokenizer(br.readLine());
			
			sb.append(Integer.parseInt(st.nextToken()) < Integer.parseInt(st.nextToken()) ? "NO" : "MMM").append(" BRAINS").append("\n");
		}
		System.out.print(sb);
	}
}
728x90
반응형

댓글