백준 #18691번 Pokemon Buddy

jhj·2024년 2월 13일

백준 JAVA

목록 보기
261/583
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int t = sc.nextInt();
		int total = 0;
		
		for(int i = 0; i < t; i++) {
			int g = sc.nextInt();
			int c = sc.nextInt();
			int e = sc.nextInt();
			
			if(g == 1) {
				total = e - c;
			}else if(g == 2) {
				total = (e - c) * 3;
			}else if(g == 3) {
				total = (e - c) * 5;
			}
			
			if(c >= e) {
				total = 0;
			}
			System.out.println(total);
		}
		sc.close();
	}
}

진화에 필요한 사탕의 개수를 이미 가지고 있을 경우를 생각하지 못하였었다!
그 경우를 생각하여 if(c >= e)인 경우를 추가하였다.

profile
개발자를 꿈꾸는

0개의 댓글