practivceAlgorithm/백준

[백준][Python] 9461 파도반 수열

findTheValue 2021. 9. 7. 03:55

간단한 dp문제. 규칙이 보인다.

 

for _ in range(int(input())):
    n = int(input())
    dp = [1,1,1,2,2]
    if n>5:
        for i in range(5,n):
            dp.append(dp[i-1]+dp[i-5])
    print(dp[n-1])

 

'practivceAlgorithm > 백준' 카테고리의 다른 글

[백준][Python] 14405 피카츄  (0) 2021.09.07
[백준][Python] 10026 적록색약  (0) 2021.09.07
[백준][Python] 9375 패션왕 신해빈  (0) 2021.09.07
[백준][Python] 9019 DSLR  (0) 2021.09.07
[백준][Python] 7569 토마토  (0) 2021.09.07