BOJ 2482 색상환

1 개요[ | ]

BOJ 2482 색상환

2 C++[ | ]

#include <bits/stdc++.h>
using namespace std;

#define MOD 1000000003
int N, K;
int A[1001][1001];

void solve() {
    for (int i=0; i<=N; i++) {
        A[i][1] = i;
        A[i][0] = 1;
    }
    for (int i=2; i<=N; i++) {
        for (int j=2; j<=K; j++) {
            A[i][j] = (A[i-2][j-1]+A[i-1][j]) % MOD;
        }
    }
    cout << ((A[N-1][K]+A[N-3][K-1]) % MOD);
}

int main() {
    cin >> N >> K;
    solve();
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}