์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฌธ์ œ/BOJ_Java

[BOJ/Step3] 11021 : A+B - 7 (JAVA)

NaNaRin๐Ÿ™ƒ 2021. 1. 7. 21:07

www.acmicpc.net/problem/11021

 

11021๋ฒˆ: A+B - 7

๊ฐ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๋งˆ๋‹ค "Case #x: "๋ฅผ ์ถœ๋ ฅํ•œ ๋‹ค์Œ, A+B๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค. ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค ๋ฒˆํ˜ธ๋Š” 1๋ถ€ํ„ฐ ์‹œ์ž‘ํ•œ๋‹ค.

www.acmicpc.net


๋ฌธ์ œ

๋‘ ์ •์ˆ˜ A์™€ B๋ฅผ ์ž…๋ ฅ๋ฐ›์€ ๋‹ค์Œ, A+B๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค.

 

์ž…๋ ฅ

์ฒซ์งธ ์ค„์— ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค์˜ ๊ฐœ์ˆ˜ T๊ฐ€ ์ฃผ์–ด์ง„๋‹ค.

๊ฐ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๋Š” ํ•œ ์ค„๋กœ ์ด๋ฃจ์–ด์ ธ ์žˆ์œผ๋ฉฐ, ๊ฐ ์ค„์— A์™€ B๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. (0 < A, B < 10)

 

์ถœ๋ ฅ

๊ฐ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๋งˆ๋‹ค "Case #x: "๋ฅผ ์ถœ๋ ฅํ•œ ๋‹ค์Œ, A+B๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค. ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค ๋ฒˆํ˜ธ๋Š” 1๋ถ€ํ„ฐ ์‹œ์ž‘ํ•œ๋‹ค.

 

์˜ˆ์ œ ์ž…๋ ฅ

5

1 1

2 3

3 4

9 8

5 2

 

์˜ˆ์ œ ์ถœ๋ ฅ

Case #1: 2

Case #2: 5

Case #3: 7

Case #4: 17

Case #5: 7


ํ’€์ด

 

import java.io.*;
import java.util.StringTokenizer;

public class B11021 {

	public static void main(String[] args) throws NumberFormatException, IOException {
	
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
		
		int num = Integer.parseInt(br.readLine());
		
		for(int i = 0; i < num; i++) {
			
			StringTokenizer st = new StringTokenizer(br.readLine());
			int a = Integer.parseInt(st.nextToken());
			int b = Integer.parseInt(st.nextToken());
			
			int c = a+b;
			bw.write("Case #" + (i+1) + ": " + c + "\n");
		}
		
		bw.flush();
		bw.close();
	}
}