https://www.acmicpc.net/problem/26529
26529번: Bunnies
You’re going to raise farm animals and you decided to start with bunnies, the easiest of animals. To your surprise they are breeding like rabbits, so much so that you’re unable to count them accurately. However, you know that rabbits’ breeding patter
www.acmicpc.net
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
def solution(n):
answer = [1, 1]
for i in range(2, n + 1):
answer.append(answer[-1] + answer[-2])
return answer[n]
if __name__ == '__main__':
t = int(input())
for i in range(t):
n = int(input())
print(solution(n))
|
cs |
이 문제도 뭐.. 피보나치 수열 문제죠
반응형
'python-algorithm' 카테고리의 다른 글
백준 30700 KOREA 문자열 만들기 (1) | 2023.11.27 |
---|---|
백준 28062 준석이의 사탕 사기 (1) | 2023.11.27 |
백준 15841 Virus Outbreak (1) | 2023.11.25 |
백준 29738 Goodbye, Code Jam (0) | 2023.11.23 |
백준 30676 이 별은 무슨 색일까 (0) | 2023.11.23 |
댓글