๐ŸŒฑ → ๐ŸŒณ

[๋ฐฑ์ค€] 1000๋ฒˆ : A+B python ๋ณธ๋ฌธ

Algorithms

[๋ฐฑ์ค€] 1000๋ฒˆ : A+B python

BAY 2022. 7. 3. 11:47
728x90

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

 

1000๋ฒˆ: A+B

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

www.acmicpc.net

 

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

a,b = input().split()
a = int(a)
b = int(b)
print(a+b)

input() ํ•จ์ˆ˜๋ฅผ ์ด์šฉํ•˜์—ฌ ์ธ์ž๋ฅผ ๋ฐ›์•„์˜จ๋‹ค. (์ด๋•Œ, ๋ฌธ์ž์—ด๋กœ ๋ฐ›์•„์˜ด)

.split()์„ ์ด์šฉํ•˜์—ฌ ์ŠคํŽ˜์ด์Šค๋ฐ”๋กœ ๊ตฌ๋ถ„ํ•ด ๋ณ€์ˆ˜๋ฅผ ์ €์žฅํ•จ

 

a = int(a)

b = int(b) ๋ฅผ ํ†ตํ•ด int๋กœ ํ˜•๋ณ€ํ™˜์„ ํ•ด ์ค€ ํ›„ 

print() ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๊ฒฐ๊ณผ๊ฐ’์„ printํ•ด ์ฃผ์—ˆ๋‹ค

 

์ด๋•Œ, map ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๋‚˜ํƒ€๋‚ผ ์ˆ˜๋„ ์žˆ๋‹ค 

map() ํ•จ์ˆ˜๋Š” ์—ฌ๋Ÿฌ ๊ฐœ์˜ ๋ฐ์ดํ„ฐ๋ฅผ ํ•œ ๋ฒˆ์— ํ˜•๋ณ€ํ™˜์„ ํ•ด์ค„ ์ˆ˜ ์žˆ๋‹ค.

a, b = map(int, input().split())
print(a+b)
728x90