whatisthis?

๋ฐฑ์ค€ 11022 javascript (node.js) ํ’€์ด ๋ณธ๋ฌธ

ALGORITHM/BOJ (Node.js)

๋ฐฑ์ค€ 11022 javascript (node.js) ํ’€์ด

thisisyjin 2021. 12. 11. 21:58

for๋ฌธ - (8)

 

 


 

๐Ÿ’ก๋ฌธ์ œ

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

๐Ÿ“์ž…๋ ฅ

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

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

๐Ÿ“ˆ์ถœ๋ ฅ

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

C๋Š” A+B์ด๋‹ค.

์˜ˆ์ œ ์ž…๋ ฅ

5
1 1
2 3
3 4
9 8
5 2

์˜ˆ์ œ ์ถœ๋ ฅ

Case #1: 1 + 1 = 2
Case #2: 2 + 3 = 5
Case #3: 3 + 4 = 7
Case #4: 9 + 8 = 17
Case #5: 5 + 2 = 7

 


< ์ฝ”๋“œ >

let input = require('fs').readFileSync('/dev/stdin').toString().split('\n');

for(let i=1;i<=input[0];i++) {
   let tmp = input[i].split(' ');
   console.log(`Case #${i}: ${Number(tmp[0])} + ${Number(tmp[1])} = ${Number(tmp[0])+Number(tmp[1])}`);
}