๋์ ํ์ด
T = int(input())
# ์ฌ๋ฌ๊ฐ์ ํ
์คํธ ์ผ์ด์ค๊ฐ ์ฃผ์ด์ง๋ฏ๋ก, ๊ฐ๊ฐ์ ์ฒ๋ฆฌํฉ๋๋ค.
for t in range(1, T + 1):
lastDay = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
result = 0
fromMon , fromDay , toMon , toDay = map(int,input().split())
if fromMon == toMon:
result = toDay - fromDay + 1
else:
for i in range(fromMon,toMon):
result += lastDay[i]
result = result + toDay - fromDay + 1
print("#"+str(t) , result)
๊ฐ ๋ฌ์ ๋ง์ง๋ง ๋ ์ ๋ฐฐ์ด๋ก ์์ฑ
์ง๊ด์ ์ผ๋ก ๋ณด๊ธฐ์ํด 0๋ฒ ์ธ๋ฑ์ค๋ 0 ๊ฐ์ผ๋ก ์์ฑ ( 1๋ฒ ์ธ๋ฑ์ค๋ 1์ )
๋๋จธ์ง๋ ๊ณ์ฐ
D1 ์์ ํ์๋ 2056. ์ฐ์์ผ ๋ฌ๋ ฅ ๋ฌธ์ ๋ ๋น์ทํ ๋๋
if fromMon == toMon:
result = toDay - fromDay + 1
์ด ์กฐ๊ฑด๋ฌธ์ ์์ด๋ ๋๊ฒ ๋ค.
for i in range(fromMon,toMon):
์ด์ฐจํผ ๋ฐ๋ณต๋ฌธ ๋ฒ์์์ ๋์ด ๊ฐ์ผ๋ฉด 1๋ฒ๋ง ์ํํ๋๊น !
๋ค๋ฅธ์ฌ๋ ํ์ด๋ ๋ค ๋น์ทํ๋ค.
๋์ ๋๋ฆฌ๋ก ํ์ด๋ ๋๊ฒ ๋ค.
'Algorithm > SWEA' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[SWEA - D2] 1970. ์ฌ์ด ๊ฑฐ์ค๋ฆ๋ (0) | 2023.04.15 |
---|---|
[SWEA - D2] 1940. ๊ฐ๋! RC์นด! (0) | 2023.04.13 |
[SWEA - D2] 1989. ์ด์ฌ์์ ํ๋ฌธ ๊ฒ์ฌ (0) | 2023.04.13 |
[SWEA - D2] 1284. ์๋ ์๊ธ ๊ฒฝ์ (1) | 2023.04.12 |
[SWEA - D2] 1288. ์๋ก์ด ๋ถ๋ฉด์ฆ ์น๋ฃ๋ฒ (0) | 2023.04.12 |