본문 바로가기
Algorithm/swea

[파이썬]swea 1948: 날짜 계산기

by 갈잃자 2023. 2. 12.

https://swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=2&contestProbId=AV5PnnU6AOsDFAUq&categoryId=AV5PnnU6AOsDFAUq&categoryType=CODE&problemTitle=&orderBy=FIRST_REG_DATETIME&selectCodeLang=ALL&select-1=2&pageSize=10&pageIndex=2 

 

SW Expert Academy

SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!

swexpertacademy.com


단순 구현문제

 

며칠 차이나는지 계산하는건데

 

해당 월에 일수를 리스트에 넣어서 처리하면 수월함

t = int(input())
for tc in range(1,t+1):
    year = [0,31,28,31,30,31,30,31,31,30,31,30,31]
    nowM, nowD, nextM, nextD = list(map(int,input().split()))
    result = 0
    if nowM != nextM:
        a = year[nowM:nextM]
        result += sum(a)

    result-= nowD-1
    result+= nextD
    print(f"#{tc} {result}")

댓글