백준 15841번: Virus Outbreak #Python

ColorlessDia·2025년 12월 5일

algorithm/baekjoon

목록 보기
747/807
import sys

input = sys.stdin.readline

dp = [0] * (490 + 1)

for i in range(1, 490 + 1):
    
    if i < 3:
        dp[i] = 1
        continue

    dp[i] = dp[i - 2] + dp[i - 1]

while True:
    H = int(input())

    if H == -1:
        break

    print(f'Hour {H}: {dp[H]} cow(s) affected')

0개의 댓글