[백준] 11727 2xn 타일링 2

0

백준

목록 보기
181/271
post-thumbnail
post-custom-banner

[백준] 11727 2xn 타일링 2

#include <algorithm>
#include <vector>
#include <iostream>
using namespace std;

typedef long long ll;

vector<ll> cache(1001, -1);

//2xn 크기 직사각형을 채우는 방법의 수
ll solve(int n) {
	//base caes
	if (n <= 1) return 1;

	ll& res = cache[n];
	if (res != -1) return res;

	res = 0LL;
	
	res += solve(n - 1);
	res %= 10007;
	
	res += (2 * solve(n - 2));
	res %= 10007;

	return res;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);

	int n;
	cin >> n;

	cout << solve(n);

	return 0;
}
profile
Be able to be vulnerable, in search of truth
post-custom-banner

0개의 댓글