UVA 11270 轮廓线

题目链接:

http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=33787

题意:

用1*2或2*1的长条把n*m方格铺满的方案数。裸的轮廓线dp。

代码:

 #include<iostream>
#include<cstdio>
#include<cstring>
using namespace std; const int maxn = ;
typedef long long LL; LL dp[][ << ];
int n, m,cur; void update(int a, int b) {
if (b&( << m)) dp[cur][b ^ ( << m)] += dp[ - cur][a];
} int main() {
while (scanf("%d%d", &n, &m) == && n) {
if (m>n) swap(n, m);
memset(dp, , sizeof(dp));
dp[][( << m) - ] = ; cur = ;
for (int i = ; i < n; i++) {
for (int j = ; j < m; j++) {
cur = - cur;
memset(dp[cur], , sizeof(dp[cur]));
for (int k = ; k < ( << m); k++) {
update(k, k << );
if (i && !(k&( << m - ))) {
update(k, (k << ) ^ ^ ( << m));
}
if (j&&!(k & )) {
update(k, (k << ) ^ );
}
}
}
}
printf("%lld\n", dp[cur][( << m) - ]);
}
return ;
}
上一篇:Js获取页面地址参数


下一篇:javascript 之获取 百度地址参数方法