【DP】HDU 1143 Tri Tiling
2014-09-01 15:40
441 查看
需要放满格子,所以N为奇数时ans应该为0;
当前格子放的状态用表示0-7的二进制来表示
初始化第一列时先令036为1
第i列可有前一列的状态转化而来
i-1列 当前第i列
7->0
6-> 1
5-> 2
4,7 -> 3
3 -> 4
2 -> 5
1,7 -> 6
3,6,0 -> 7
当前格子放的状态用表示0-7的二进制来表示
初始化第一列时先令036为1
第i列可有前一列的状态转化而来
i-1列 当前第i列
7->0
6-> 1
5-> 2
4,7 -> 3
3 -> 4
2 -> 5
1,7 -> 6
3,6,0 -> 7
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <math.h> #include <string> #include <iostream> #include <algorithm> using namespace std; #include <queue> #include <stack> #include <vector> #include <deque> #include <set> #include <map> #define IN freopen ("in.txt" , "r" , stdin); #define OUT freopen ("out.txt" , "w" , stdout); typedef long long LL; const int MAXN = 1111111;//点数的最大值 const int MAXM = 20006;//边数的最大值 const int INF = 11521204; const int mod=1000000007; int dp[1111][9]; int main() { int n,m,q; while(scanf("%d",&n),n!=-1) { memset(dp,0,sizeof(dp)); dp[0][7]=dp[1][0]=dp[1][3]=dp[1][6]=1; for(int i=2;i<=n;i++) { dp[i][0]=dp[i-1][7]; dp[i][1]=dp[i-1][6]; dp[i][2]=dp[i-1][5]; dp[i][3]=dp[i-1][7]+dp[i-1][4]; dp[i][4]=dp[i-1][3]; dp[i][5]=dp[i-1][2]; dp[i][6]=dp[i-1][7]+dp[i-1][1]; dp[i][7]=dp[i][1]+dp[i][4]+dp[i-1][0]; } printf("%d\n",dp [7]); } return 0; }
相关文章推荐
- HDU 1143 Tri Tiling(dp)
- HDU 1143 Tri Tiling (状压DP)
- 【DP】HDU 1143 Tri Tiling
- hdu 1143 Tri Tiling (DP)
- hdu 1143 Tri Tiling (DP)
- HDU 1143 Tri Tiling
- HDU 1143 Tri Tiling (数学)
- HDU_1143_tri tiling
- hdu 1143 Tri Tiling
- HDU 1143 Tri Tiling
- HDU 1143 Tri Tiling (递推)
- hdu 1143 Tri Tiling 递推
- HDU 1143 Tri Tiling 【递推】
- hdu-1143-Tri Tiling
- HDU 1143 Tri Tiling (递推)
- HDU 1143 Tri Tiling
- HDU 1143 Tri Tiling
- hdu 1143 Tri Tiling
- hdu 1143 Tri Tiling
- HDU1143 - Tri Tiling(插头DP)