You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.5 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#include <bits/stdc++.h>
using namespace std;
const int MOD = 10000;
// 功能从后向前考查保证填充满的情况下计算在第x列放了count个小方块情况下有多少种办法
// 参数x:当前考查的是第x列
// 参数count:在x列放了几个位置范围是 0个与1个
int dfs(int x, int count) {
if (x == 0) {
//第0列而且还放了一个这种情况是不可能发生的所以方案数为0
if (count == 1) return 0;
//第0列个数为0是正确的是有返回递归终点值的,值为1
return 1;
}
//出现了不可能发生的负值情况返回0
if (x < 0) return 0;
//结果变量
int ans = 0;
//如果x列没有小方格被放下
//情况1放一个竖的前面的可能性就是 dfs(x-1,0)
//情况2放两个横的前面的可能性就是 dfs(x-2,0)
//情况3放一个向左下开口的L或者放一个向左上开口的L,都会造成前面的剩余中产生第x-1列是一个小方格被放下的情况产生即dfs(x-1,1)
if (count == 0) ans = (ans + dfs(x - 1, 0) + dfs(x - 2, 0) + 2 * dfs(x - 1, 1)) % MOD;
//如果x列有一个小方格被放下
//情况1用一个L可以搞定就是 dfs(x-2,0)
//情况2用横着的放进来就会造成x-1列出现一个小方格的情况即 dfs(x-1,1)
if (count == 1) ans = (ans + dfs(x - 2, 0) + dfs(x - 1, 1)) % MOD;
return ans;
}
int main() {
int n;
cin >> n;
cout << dfs(n, 0);
}