Algorithm/유형별 : DP
[C++] [DP] 백준 11727번 : 2xN 타일링 2
쟌쥰
2020. 2. 2. 13:28
https://www.acmicpc.net/problem/11727
11727번: 2×n 타일링 2
첫째 줄에 2×n 크기의 직사각형을 채우는 방법의 수를 10,007로 나눈 나머지를 출력한다.
www.acmicpc.net
#include<iostream>
using namespace std;
int tail[1001];
int dp(int n) {
if (n == 1)return 1;
if (n == 2)return 3;
if (tail[n] != 0)return tail[n];
return tail[n] = (dp(n - 1) + (2 * dp(n - 2))) % 10007;
}
int main(void) {
int n;
cin >> n;
cout << dp(n) << endl;
}