BOJ - 9507 - Generations of Tribbles

Updated:

import sys

def solution():
    T = int(sys.stdin.readline())
    for i in range(T):
        arr = [1, 1, 2, 4]
        N = int(sys.stdin.readline())
        for j in range(4, N + 1):
            arr.append(arr[j - 1] + arr[j - 2] + arr[j - 3] + arr[j - 4])
        print(arr[N])

solution()

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

Categories:

Updated:

Leave a comment