一个比较简单的状压dp,记录下每个点的状态即可。

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int maxn=13;
long long dp[maxn][maxn][2100];
int main()
{
int n,m;
while(scanf("%d %d",&n,&m),n||m)
{
int tmp=1<<m;
memset(dp,0,sizeof(dp));
dp[1][1][0]=1;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
for(int k=0;k<tmp;k++)
if(k&(1<<j-1))
{
dp[i][j+1][k^(1<<j-1)]+=dp[i][j][k];
}
else
{
dp[i][j+1][k|(1<<j-1)]+=dp[i][j][k];
if(j!=m)
if((k&(1<<j))==0)
dp[i][j+1][k|(1<<j)]+=dp[i][j][k];
}
for(int k=0;k<tmp;k++)
dp[i+1][1][k]=dp[i][m+1][k];
}
cout<<dp[n][m+1][0]<<endl;
}
return 0;
}

poj 2411 Mondriaan's Dream dp的更多相关文章

  1. POJ 2411 Mondriaan's Dream 插头dp

    题目链接: http://poj.org/problem?id=2411 Mondriaan's Dream Time Limit: 3000MSMemory Limit: 65536K 问题描述 S ...

  2. POJ 2411 Mondriaan's Dream -- 状压DP

    题目:Mondriaan's Dream 链接:http://poj.org/problem?id=2411 题意:用 1*2 的瓷砖去填 n*m 的地板,问有多少种填法. 思路: 很久很久以前便做过 ...

  3. Poj 2411 Mondriaan's Dream(压缩矩阵DP)

    一.Description Squares and rectangles fascinated the famous Dutch painter Piet Mondriaan. One night, ...

  4. POJ - 2411 Mondriaan's Dream(轮廓线dp)

    Mondriaan's Dream Squares and rectangles fascinated the famous Dutch painter Piet Mondriaan. One nig ...

  5. Poj 2411 Mondriaan's Dream(状压DP)

    Mondriaan's Dream Time Limit: 3000MS Memory Limit: 65536K Description Squares and rectangles fascina ...

  6. [poj 2411]Mondriaan's Dream (状压dp)

    Mondriaan's Dream Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 18903 Accepted: 10779 D ...

  7. [POJ] 2411 Mondriaan's Dream

    Mondriaan's Dream Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 18903 Accepted: 10779 D ...

  8. poj 2411 Mondriaan's Dream(状态压缩dP)

    题目:http://poj.org/problem?id=2411 Input The input contains several test cases. Each test case is mad ...

  9. poj 2411 Mondriaan's Dream(状态压缩dp)

    Description Squares and rectangles fascinated the famous Dutch painter Piet Mondriaan. One night, af ...

随机推荐

  1. AdTime:多屏时代下传统媒体的鼓起

    watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMzk1MTQzNQ==/font/5a6L5L2T/fontsize/400/fill/I0JBQk ...

  2. 基于visual Studio2013解决面试题之1001去除数字

     题目

  3. php导出excel数据

    提供两种导出excel方法 1 最简单的导出excel header('Content-Type: application/vnd.ms-excel'); //设置文件类型   也可以将 vnd.ms ...

  4. poj 1564 Sum It Up | zoj 1711 | hdu 1548 (dfs + 剪枝 or 判重)

    Sum It Up Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Sub ...

  5. C++断言assert

    assert宏是在标准库中提供的.它在库文件<cassert>中声明,它能够在程序中測试逻辑表达式,假设指定的逻辑表达式是false,assert()就会终止程序,并显示诊断消息.关闭断言 ...

  6. perl post 请求带参数

    my $url='https://wenjinbao.winfae.com/business/dispatch_post.do?action=submitAdminLogin';    my $res ...

  7. cocos2d-x游戏开发系列教程-坦克大战游戏加载地图的编写

    上节课写了关卡选择场景,那么接下来写关卡内容,先写最基本的地图的加载 我们新建一个场景类,如下所示: class CityScene : public cocos2d::CCLayer { publi ...

  8. Servlet的学习之Session(3)

    在上一篇<Servlet的学习之Session(2)>我们知道了Session能实现一个会话过程中保存数据或者多个会话中实现同一个Session的关键因素就是Cookie,只是Cookie ...

  9. 测试framebuffer

    static GGLContext *gr_context = 0; static GGLSurface gr_framebuffer[2]; static unsigned gr_active_fb ...

  10. Selenium WebDriver TestNg Maven Eclipse java 简单实例

    环境准备 前提条件Eclipse 已经安装过 TestNg ,Maven 插件 新建一个普通的java项目 点击右键 configure->convert to Maven Project 之后 ...