๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Algorithm/๋ฐฑ์ค€(BOJ)

[ ํŒŒ์ด์ฌ(python) ] ๋ฐฑ์ค€ 1924 - 2007๋…„

by YWTechIT 2021. 4. 28.
728x90

๐Ÿ“ ๋ฐฑ์ค€ 1924 - 2007

๋ฐฑ์ค€ 1924 - 2007


โšก๏ธ ๋‚˜์˜ ํ’€์ด

๋‚ ์งœ ๋งž์ถ”๋Š” ๋ฌธ์ œ๋‹ค. ์ €๋ฒˆ์— ํ’€์—ˆ๋Š”๋ฐ ์˜ค๋žœ๋งŒ์— ํ’€๋ ค๋‹ˆ๊นŒ ๊นŒ๋จน์—ˆ๋‹ค.
์ค‘๊ฐ„์— ๋‚ ์งœ๋ฅผ 7๋กœ ๋‚˜๋ˆˆ ๋‚˜๋จธ์ง€๋ฅผ ๊ตฌํ•˜๋Š” ๊ฒƒ๊ณผ array์— ์ „์ฒด ๋งค ๋‹ฌ์„ ๋„ฃ๊ณ  ๊ตฌํ•˜๋Š” ๊ฒƒ๊นŒ์ง€๋Š” ๊ธฐ์–ต์ด ๋‚ฌ๋Š”๋ฐ, ๊ทธ ์ดํ›„์—๋Š” ๊ธฐ์–ต์ด ๋‚˜์ง€ ์•Š์•˜๋‹ค.

 

  1. ๊ตฌํ•ด์•ผํ•˜๋Š” ๋‹ฌ ์ด์ „ ๋‹ฌ(x-1)๊นŒ์ง€ ๊ฐ’์„ ๋”ํ•˜๊ณ (sum) ๊ตฌํ•ด์•ผ ํ•˜๋Š” ์ผ(y)์„ ๋”ํ•œ๋‹ค.
  2. ์ „์ฒด ๊ฐ’์„ 7๋กœ ๋‚˜๋ˆ ์ฃผ๊ณ  ๋‚˜๋จธ์ง€๊ฐ’์„ days์— ๋ถ™์—ฌ์ค€๋‹ค.
  3. ๋ฌธ์ œ์— 1์›” 1์ผ์ด ์›”์š”์ผ์ด๋ผ๊ณ  ๋‚˜์™€์žˆ์–ด days[1]๋ถ€ํ„ฐ MON์„ ์ž‘์„ฑํ–ˆ๋‹ค.
x, y = map(int, input().split())

months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
days = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']

print(days[(sum(months[:x-1])+y) % 7])

 

๋ฐ˜์‘ํ˜•

๋Œ“๊ธ€