https://www.acmicpc.net/problem/15841
15841번: Virus Outbreak
For each input value, the output contains a line in the format: Hour X: Y cow(s) affected, where X is the hour, and Y is the total affected cows that need to be euthanized based on the hour given by X.
www.acmicpc.net
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
def solution(n):
answer = [0, 1, 1]
for i in range(3, n + 1):
answer.append(answer[-1] + answer[-2])
return answer[n]
if __name__ == '__main__':
while True:
n = int(input())
if n == -1:
break
print(f'Hour {n}: {solution(n)} cow(s) affected')
|
cs |
이 문제는.. 바이러스가 피보나치 수열로 증가하고 있습니다
반응형
'python-algorithm' 카테고리의 다른 글
백준 28062 준석이의 사탕 사기 (1) | 2023.11.27 |
---|---|
백준 26529 Bunnies (1) | 2023.11.25 |
백준 29738 Goodbye, Code Jam (0) | 2023.11.23 |
백준 30676 이 별은 무슨 색일까 (0) | 2023.11.23 |
백준 30033 Rust Study (0) | 2023.11.16 |
댓글