https://www.acmicpc.net/problem/27332
27332번: 11 月 (November)
2022 年 11 月 3 日の 4 週間後の日は 2022 年 12 月 1 日である.この日は 2022 年 11 月ではないので 0 を出力する.
www.acmicpc.net
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
import datetime
def sol(a, b):
current_date = datetime.date(2022, 11, a)
weeks = datetime.timedelta(weeks=b)
that_day = current_date + weeks
if that_day.year == 2022 and that_day.month == 11:
return 1
else:
return 0
if __name__ == '__main__':
a = int(input())
b = int(input())
print(sol(a, b))
|
cs |
시간 관련 문제는
1. 시,분,초 단위면 ==> '초' 단위로 바꿔서 해결한다.
2. 년, 월, 일 단위면 datetime 라이브러리를 사용한다.
time related issues
1. If hour, minute, second unit ==> Change it to 'second' unit and solve it.
2. Use the datetime library for year, month, and day units.
반응형
'python-algorithm' 카테고리의 다른 글
leetcode 937. Reorder Data in Log Files (0) | 2023.02.07 |
---|---|
leetcode 1967. Number of Strings That Appear as Substrings in Word (2) | 2023.02.03 |
백준 27294 몇개고? (0) | 2023.01.31 |
백준 27328 三方比較 (Three-Way Comparison) (0) | 2023.01.31 |
백준 27327 時間 (Hour) (0) | 2023.01.31 |
댓글