백준 1476 python [날짜 계산]

인지용·2025년 1월 28일
0

알고리즘

목록 보기
28/46
post-thumbnail

https://www.acmicpc.net/problem/1476

import sys

# with open("./data.txt", "r") as file:
    # def input():
    #     return file.readline().strip()
    
def input():
    return sys.stdin.readline()


E, S, M = map(int, input().split(" "))
e = 0
s = 0
m = 0
year = 0

while True: 
    year += 1
    
    e += 1
    s += 1
    m += 1
    
    if(e > 15):
        e = 1
    
    if(s > 28):
        s = 1
    
    if(m > 19):
        m = 1

    if(E == e and S == s and M == m):
        break

print(year)

지구, 해, 달을 다 1씩 올려준 후
각자 정해진 최대 값을 초과하면 1로 초기화 해주는걸

주어진 값과 일치할 때 까지 반복하면 된다!

profile
한-줄

0개의 댓글