본문 바로가기

CodingTest/SW Expert Academy

[ SW Expert Academy ] 1948. 날짜 계산기

1차 제출. [ 10 / 10 ] PASS

아.. 감격스럽다.. 이 문제 맞춘거

7월인가에 이거랑 비슷한 문제 못 풀어낸 경험 있어서 보자마자 흠칫했다. 

괜히 쫄았네 : ) 

T = int(input())
month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]

for tc in range(1, T+1):
    month1, date1, month2, date2 = map(int, input().split())
    if month1 == month2:
        total_dates = date2-date1+1
    else:
        month1 -= 1
        month2 -= 1
        total_dates = month[month1] - date1 + 1 + sum(month[month1+1:month2]) + date2
    print('#{} {}'.format(tc, total_dates))