본문 바로가기
python-algorithm

백준 26529 Bunnies

by 무적김두칠 2023. 11. 25.

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 = [11]
    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

이 문제도 뭐.. 피보나치 수열 문제죠

반응형

댓글