[๋ฐฑ์ค€ / Swift] 10951 - A+B-4

๋ฐ•์ค€ํ˜ - Niroยท2023๋…„ 1์›” 6์ผ
0

๋ฐฑ์ค€

๋ชฉ๋ก ๋ณด๊ธฐ
2/16
post-thumbnail

๐Ÿ”— ๋ฌธ์ œ ๋งํฌ


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

๐Ÿ’ก ๋ฌธ์ œ


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

โŒจ๏ธ ์ž…๋ ฅ


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

๐Ÿ–จ๏ธ ์ถœ๋ ฅ


๊ฐ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๋งˆ๋‹ค A+B๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค.

โœ… ํ’€์ด


ํ•ด๋‹น ๋ฌธ์ œ๋Š” ๋‘ ์ˆ˜๋ฅผ ๋”ํ•ด ์ถœ๋ ฅํ•˜๋Š” ์•„์ฃผ ์‰ฌ์šด ๋ฌธ์ œ์ด์ง€๋งŒ ๊ฒ€์ƒ‰์„ ํ•ด์„œ ํ’€์ด๋ฅผ ๋ณด๊ณ  ์žˆ๋‹ค๋Š” ๊ฒƒ์€ ์•„๋งˆ ๊ณ„์†ํ•ด์„œ ๋Ÿฐํƒ€์ž„ ์—๋Ÿฌ ๊ฐ€ ๋‚˜์™”์„ ๊ฒƒ์ž…๋‹ˆ๋‹ค.

์ด ๋ฌธ์ œ์—์„œ ๊ฐ€์žฅ ์ค‘์š”ํ•œ ๊ฒƒ์€ ๋ฌดํ•œ ๋ฃจํ”„๊ฐ€ ๋Œ ๋•Œ ์–ด๋–ป๊ฒŒ ๋น ์ ธ๋‚˜์˜ฌ ๊ฒƒ์ธ์ง€์— ๊ด€ํ•œ ๋ฌธ์ œ ์ž…๋‹ˆ๋‹ค.

๊ณ„์† ์ž…๋ ฅํ•˜๋Š” ๊ฒƒ์ด ์•„๋‹ˆ๊ธฐ ๋•Œ๋ฌธ์— while ๋ฌธ์˜ ์กฐ๊ฑด์„ true ๊ฐ€ ์•„๋‹Œ ์ž…๋ ฅ์„ ๋ฐ›์•˜์„ ๋•Œ๋งŒ ๋ฐ˜๋ณต ํ•˜๋„๋ก ํ•˜์—ฌ์•ผํ•ฉ๋‹ˆ๋‹ค.

๐Ÿ–ฅ๏ธ ์†Œ์Šค ์ฝ”๋“œ


while let input = readLine(){
    print(input.split(separator: " ").map{Int(String( $0 ))!}.reduce(0, +))
}
profile
๐Ÿ“ฑiOS Developer, ๐ŸŽย Apple Developer Academy @ POSTECH 1st, ๐Ÿ’ป DO SOPT 33th iOS Part

0๊ฐœ์˜ ๋Œ“๊ธ€