[백준] 1476번 (python 파이썬) 날짜계산
2021. 3. 23. 19:13ㆍ발돋움/알고리즘
728x90
반응형

e, s, m = map(int, input().split())
s = time.time()
year = 1
while True:
if (year % 15 == e) & (year % 28 == s) & (year % 19 == m):
print(year)
break
year += 1
처음에는 위와 같은 코드로 정답이 잘 나오길래 제출을 했는데 시간초과가 났다.
728x90
e, s, m = map(int, input().split())
e -= 1
s -= 1
m -= 1
year = 0
while True:
if year % 15 == e and year % 28 == s and year % 19 == m:
print(year + 1)
break
year += 1
위와 같이 바꾸니 정답이 맞았다. year와 각 날짜가 1 차이 나는 것 빼고는 똑같은데 왜 그런지 모르겠다.
728x90
반응형
'발돋움 > 알고리즘' 카테고리의 다른 글
| [백준] 1748번 (python 파이썬) 수 이어 쓰기1 (0) | 2021.03.24 |
|---|---|
| [백준] 1107번 (python 파이썬) 리모컨 (0) | 2021.03.23 |
| [백준] 3085번 (python 파이썬) 사탕게임 (0) | 2021.03.23 |
| [백준] 15655번 (python 파이썬) N과 M(6) (0) | 2021.03.23 |
| [백준] 15650번 (python 파이썬) N과 M(2) (0) | 2021.03.23 |