uva11270 Tiling Dominoes
来源:互联网 发布:linux查看挂载目录 编辑:程序博客网 时间:2024/05/24 06:45
Given a rectangular grid, with dimensions m n , compute the number
of ways of completely tiling it with dominoes. Note that if the
rotation of one tiling matches another, they still count as different
ones. A domino is a shape formed by the union of two unit squares
meeting edge-to-edge. Equivalently, it is a matching in the grid graph
formed by placing a vertex at the center of each square of the region
and connecting two vertices when they correspond to adjacent squares.
An example of a tiling is shown below. Input The input will consist of
a set of lines with mn , given the restriction n m<
101. Output For each line of input, output the number of tilings in a separate line.
插头dp。
对于当前位置,如果上面为空只能往上放,否则的话,可以不放,如果左边为空还可以放左边。
#include<cstdio>#include<cstring>#include<algorithm>using namespace std;#define LL long longLL dp[2][3010];int n,m;int main(){ int b,flag; while (scanf("%d%d",&n,&m)==2) { if (n<m) swap(n,m); memset(dp,0,sizeof(dp)); flag=(1<<m)-1; dp[0][flag]=1; b=0; for (int i=0;i<n;i++) for (int j=0;j<m;j++) { b^=1; memset(dp[b],0,sizeof(dp[b])); for (int k=0;k<=flag;k++) { if (k&(1<<m-1)) dp[b][(k<<1)&flag]+=dp[b^1][k]; if (i&&!(k&(1<<m-1))) dp[b][((k<<1)&flag)|1]+=dp[b^1][k]; if (j&&!(k&1)&&(k&1<<m-1)) dp[b][((k<<1)&flag)|3]+=dp[b^1][k]; } } printf("%lld\n",dp[b][flag]); }}
- uva11270 Tiling Dominoes
- 【动态规划】[Uva11270]Tiling Dominoes
- uva11270 - Tiling Dominoes 插头DP
- UVA11270 Tiling Dominoes 轮廓线|插头 DP入门
- Tiling Dominoes
- UVA - 11270 Tiling Dominoes
- Tiling Dominoes UVA
- 【DP】 UVA 11270 Tiling Dominoes
- 7.13 LUVA 11270Tiling Dominoes
- Tiling a Grid With Dominoes
- UVA11270
- hdu 1992 Tiling a Grid With Dominoes
- Sicily 1527. Tiling a Grid With Dominoes
- sicily 1527. Tiling a Grid With Dominoes
- hdu 1992 Tiling a Grid With Dominoes
- hdu 1992 Tiling a Grid With Dominoes
- UVA 11270 Tiling Dominoes(插头DP)
- uva 11270 - Tiling Dominoes(插头dp)
- windows10 双屏幕扩展后,窗口拖动方向的问题。
- iOS UIslider 设定滑块的大小
- win10 uwp 简单MasterDetail
- bzoj 1370 团伙 并查集
- Redis之——搭建高可用及负载均衡的Redis
- uva11270 Tiling Dominoes
- maven阿里仓库
- MySQL查看当前数据库
- LeetCode Problem No1 Two Sum
- 网络编程学习笔记一
- distinct 去重问题
- 最小 最大 平均值(文件)
- 【Linux基础学习之一】关于Linux的一些基本操作(linux登陆、口令文件、多终端登陆)
- Tomcat部署时war和war exploded区别以及平时踩得坑