117272 XNタイル2(C++)


#include <iostream>
using namespace std;

int main() {
    int n;
    cin >> n;
    int d[1000];

    d[1] = 1;
    d[2] = 3;
    for (int i = 3; i <= n; i++) {
        d[i] = (d[i - 1] + 2 * d[i - 2]) % 10007;
    }
    cout << d[n];
}
動的プログラミングの説明投稿->
https://velog.io/@kimeunseo58/%EB%8B%A4%EC%9D%B4%EB%82%98%EB%AF%B9%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%B0%8D