본문 바로가기

알고리즘 문제풀이

백준 1476 날짜계산 Python 수학 브루트포스실버5

실수한 부분

if jun_e == e and jun_s==s and jun_m==m:
    break

나머지가 0이 나올 때 :15 28 19 일 경우 jun_e 가 0 이되서 15랑 같지 않다고 나옴

정답코드

# 1476 날짜계산 실5

'''
지구 e 15
태양 s 28
 달 m 19
 
'''
e,s,m = map(int,input().split())
i = 0 # 초기화
jun_e = 0
jun_s = 0
jun_m = 0
while True:
    i += 1 # 1년씩 늘어남
    jun_e = i % 15
    jun_s = i % 28
    jun_m = i % 19
    if jun_e == e%15 and jun_s==s%28 and jun_m==m%19:
        break
print(i)