[백준] #1308 D-Day python
2023. 5. 29. 22:09
https://www.acmicpc.net/problem/1308
1308번: D-Day
첫째 줄에 오늘의 날짜가 주어지고, 두 번째 줄에 D-Day인 날의 날짜가 주어진다. 날짜는 연도, 월, 일순으로 주어지며, 공백으로 구분한다. 입력 범위는 1년 1월 1일부터 9999년 12월 31일 까지 이다.
www.acmicpc.net
📕 설명 📕
python의 list를 사용하고,
python의 datetime의 toordinal이라는 것을 알게되었다.
🧑🏻💻 나의 풀이 🧑🏻💻
from datetime import *
today = list(map(int, input().split()))
d_day = list(map(int, input().split()))
if today[0] + 1000 < d_day[0]:
print("gg")
elif today[0] + 1000 == d_day[0] and (today[1], today[2]) <= (d_day[1], d_day[2]):
print("gg")
else:
today = date(*today)
d_day = date(*d_day)
print("D-"+str(d_day.toordinal() - today.toordinal()))
'Programming > Algorithm' 카테고리의 다른 글
[백준] #1629 곱셈 python (0) | 2023.05.31 |
---|---|
[백준] #2168 타일 위의 대각선 python (2) | 2023.05.30 |
[백준] #1240 노드사이의 거리 python (0) | 2023.05.26 |
[백준] #1972 놀라운 문자열 python (0) | 2023.05.25 |
[백준] #1431 시리얼 번호 python (0) | 2023.05.24 |