티스토리 뷰
Difficulty : Silver V
Problem Description
Two dates are given. First is start date, and second is end date.
If the difference between two dates is over 1000 years, the result is 'gg'.
Otherwise, the result is 'D-x'. 'x' means the difference of two dates.
Solution
Import datetime to use date library.
First, store two dates at (y1, m1, d1) and (y2, m2, d2).
Compare two dates if the difference is over 1000 years.
Otherwise, print the difference of two dates using 'datetime.date'.
Today's Code
datetime.date(yy, mm, dd) : 날짜 관련 변수, datetime을 import해야 함. 덧셈과 뺄셈이 가능하다.
X.days : 시간을 제외하고 날짜만을 출력한다.
Today's English
'프로그래밍 문제풀이 > 백준 문제풀이' 카테고리의 다른 글
1018번: 체스판 다시 칠하기 (0) | 2022.10.22 |
---|---|
1157번: 단어 공부 (0) | 2022.10.22 |
1874번: 스택 수열 (0) | 2022.10.20 |
1010번: 다리 놓기 (0) | 2022.10.19 |
1271번: 엄청난 부자2 (0) | 2022.10.17 |