zoukankan      html  css  js  c++  java
  • 【poj2411】 Mondriaan's Dream

    http://poj.org/problem?id=2411 (题目链接)

    题意

      一个$n*m$的网格,用$1*2$的方块填满有多少种方案。

    Solution

      轮廓线dp板子。按格dp,对上方和左方的格子的占用情况进行讨论转移。0表示已放置,1表示未放置。

    细节

      LL,滚动清空数组。

    代码

    // poj2411
    #include<algorithm>
    #include<iostream>
    #include<cstdlib>
    #include<cstring>
    #include<cstdio>
    #include<cmath>
    #define LL long long
    #define HAS 4001
    #define inf 2147483640
    #define Pi acos(-1.0)
    #define free(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout);
    using namespace std;
    
    const int maxs=100010;
    LL f[2][maxs];
    int n,m,bin[30];
    
    int main() {
    	bin[0]=1;for (int i=1;i<=20;i++) bin[i]=bin[i-1]<<1;
    	while (scanf("%d%d",&n,&m)!=EOF && n && m) {
    		memset(f,0,sizeof(f));
    		int p=0;f[0][0]=1;
    		for (int i=0;i<n;i++)
    			for (int j=0;j<m;j++) {
    				p^=1;memset(f[p],0,sizeof(f[p]));
    				for (int st=0;st<bin[m];st++) if (f[p^1][st]) {
    						int left=j ? st>>(j-1)&1 : 0,up=st>>j&1;
    						if (up) f[p][st^bin[j]]+=f[p^1][st];
    						else {
    							if (left) f[p][st^bin[j-1]]+=f[p^1][st];
    							f[p][st^bin[j]]+=f[p^1][st];
    						}
    					}
    			}
    		printf("%lld
    ",f[p][0]);
    	}
        return 0;
    }
    
  • 相关阅读:
    ffmpeg之AVFrame
    ffmpeg之samplefmt
    音视频基本概念
    cmake函数 file
    ffmpeg之AVPacket
    ffmpeg之AVFormatContext
    存储格式:packed和planar
    ffmpeg之channel_layout
    cmake函数: get_filename_component
    ffmpeg整体结构
  • 原文地址:https://www.cnblogs.com/MashiroSky/p/6417168.html
Copyright © 2011-2022 走看看