https://www.acmicpc.net/problem/1308
1308번: D-Day
첫째 줄에 오늘의 날짜가 주어지고, 두 번째 줄에 D-Day인 날의 날짜가 주어진다. 날짜는 연도, 월, 일순으로 주어지며, 공백으로 구분한다. 입력 범위는 1년 1월 1일부터 9999년 12월 31일 까지 이다.
www.acmicpc.net
https://docs.python.org/ko/3/library/datetime.html
datetime — Basic date and time types
Source code: Lib/datetime.py The datetime module supplies classes for manipulating dates and times. While date and time arithmetic is supported, the focus of the implementation is on efficient attr...
docs.python.org
풀이
Python에서 제공하는 datetime 모듈을 활용하여 간단하게 풀 수 있다.
1. date(year, month, day)로 date 타입 변환
2. date.toordinal()을 통해 1년 1월 1일부터 year년 month월 day일 까지의 날자 자동 계산 (윤년 포함)
키 포인트
깃허브
https://github.com/Damnun/Tour_Of_Baekjoon/blob/master/1000/Baekjoon_No1308.py
'백준 알고리즘 (Baekjoon Algorithm)' 카테고리의 다른 글
[파이썬] 백준 알고리즘 No.15815 천재 수학자 성필 (후위 연산자) (0) | 2024.01.19 |
---|---|
[파이썬] 백준 알고리즘 No.1024 수열의 합 (0) | 2024.01.16 |
[파이썬] 백준 알고리즘 No.2477 참외밭 (2) | 2023.02.18 |
[파이썬] 백준 알고리즘 No.11478 서로 다른 부분 문자열의 개수 (0) | 2023.02.18 |
[파이썬] 백준 알고리즘 No.1269 대칭 차집합 (0) | 2023.02.18 |