백준 2139번: 나는 너가 살아온 날을 알고 있다 #Python

ColorlessDia·2024년 3월 25일

algorithm/baekjoon

목록 보기
125/836
import sys

date_range = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

while True:
    date, month, year = map(int, sys.stdin.readline().split())

    if month == date == year == 0:
        break
    
    count = 0

    if (year % 4 == 0 and year % 100 != 0) or year % 400 == 0:
        count = sum(date_range[:month]) + date

        if 2 < month:
            count += 1
    else:
        count = sum(date_range[:month]) + date
    
    print(count)

0개의 댓글