algorithm/BOJ

BOJ 9461번 파도반 수열

_JunHo 2020. 1. 9. 21:04

BOJ : https://www.acmicpc.net/problem/9461

GitHub : https://github.com/junho0956/Algorithm/blob/master/9461/9461/%EC%86%8C%EC%8A%A4.cpp

 

시계방향으로 그려지는 파도반수열은

-2, -3번째 수열과 만난 합으로 그려진다.

 

더보기
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
using namespace std;
 
long long dp[101= { 0,1,1,1,};
 
int main() {
    ios::sync_with_stdio(false);
    int T, N;
 
    for (int i = 4; i <= 100; i++)
        dp[i] = dp[i - 2+ dp[i - 3];
 
    cin >> T;
    while (T--) {
        cin >> N;
        cout << dp[N] << '\n';
    }
 
    return 0;
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter