본문 바로가기

[SWEA] - Python

[SWEA/D2] 1948 : 날짜계산기 python

https://swexpertacademy.com/main/code/problem/problemDetail.do

 

우선 각 달의 일수를 days라는 list에 저장한다.

5/5와 8/15가 주어졌다고 했을 때

days[5]+days[6]+days[7]+d2-d1를 계산해주면 된다.

 

T = int(input())
days = [0,31,28,31,30,31,30,31,31,30,31,30,31]
for test_case in range(1, T + 1):
    m1, d1, m2, d2 = map(int,input().split())
    total = 1
     
    for i in range(m1,m2):
        total += days[i]
    total = total-d1+d2
    print('#%d'%test_case,'%d'%total)