문제📖
![](https://velog.velcdn.com/images%2Fcosmos%2Fpost%2F068a7a59-1b09-4dd9-bd48-8889b0010cb4%2F%E1%84%89%E1%85%B3%E1%84%8F%E1%85%B3%E1%84%85%E1%85%B5%E1%86%AB%E1%84%89%E1%85%A3%E1%86%BA%202021-03-19%20%E1%84%8B%E1%85%A9%E1%84%8C%E1%85%A5%E1%86%AB%2011.42.39.png)
풀이🙏
- 준규는 이상한곳에 산다.
- 첫째 줄에 세 수 E, S, M이 주어진다.
- (1 ≤ E ≤ 15, 1 ≤ S ≤ 28, 1 ≤ M ≤ 19)
- 첫째 줄에 E S M으로 표시되는 가장 빠른 연도를 출력한다.
- 1 1 1 은 항상 1이기 때문에, 정답이 음수가 나오는 경우는 없다.
-> while 반복문
+ 증감표현식 변수
+ if 조건문
으로 구현하였다.
-> if earth == E and sun ==S and moon == M
보다는 python coding convention PEP8
에 따른 all
사용이 더 좋다.
코드💻
import sys
def date_calculation(E, S, M):
cnt = 1
while True:
earth = cnt % 15
if earth is 0:
earth = 15
sun = cnt % 28
if sun is 0:
sun = 28
moon = cnt % 19
if moon is 0:
moon = 19
if all((earth is E, sun is S, moon is M)):
break
else:
cnt += 1
return cnt
E, S, M = map(int,sys.stdin.readline().split())
print(date_calculation(E, S, M))
결과😎
![](https://velog.velcdn.com/images%2Fcosmos%2Fpost%2Fc946d66a-7087-4670-9076-e9fe83c238d0%2F%E1%84%89%E1%85%B3%E1%84%8F%E1%85%B3%E1%84%85%E1%85%B5%E1%86%AB%E1%84%89%E1%85%A3%E1%86%BA%202021-03-19%20%E1%84%8B%E1%85%A9%E1%84%92%E1%85%AE%201.19.27.png)
출처 && 깃허브📝
https://www.acmicpc.net/problem/1476
github