[HihoCoder]#1048 : 状态压缩·二
2016-07-31 21:45
253 查看
华电北风吹
天津大学认知计算与应用重点实验室
2016-07-31
题目链接:
http://hihocoder.com/problemset/problem/1048
题目分析:
基本的状态压缩类型题目。
参考代码:
天津大学认知计算与应用重点实验室
2016-07-31
题目链接:
http://hihocoder.com/problemset/problem/1048
题目分析:
基本的状态压缩类型题目。
参考代码:
#include <stdio.h> #include <string.h> #define MaxN 1005 #define Mod 1000000007 int state[MaxN][1 << 5]; bool Check(int s1, int s2, int m) { if ((s1&s2) > 0) { return false; } int s = s1 | s2; int countNull = 0; for (int i = 0; i < m; i++) { if (((1 << i) & s) == 0) { countNull++; } else { if (countNull & 1) return false; countNull = 0; } } if (countNull & 1) return false; return true; } int main() { int N, M; scanf("%d %d", &N, &M); memset(state, 0, sizeof(state)); state[0][0] = 1; for (int i = 1; i <= N; i++) { for (int j = 0; j < (1 << M); j++) { for (int k = 0; k < (1 << M); k++) { if (Check(k, j, M)) { state[i][j] += state[i - 1][k]; state[i][j] = state[i][j] % Mod; } } } } printf("%d\n", state [0]); return 0; }
相关文章推荐
- hihocoder-1048 状态压缩·二(状压DP)
- hihocoder-#1048 : 状态压缩·二
- hihoCoder1048 : 状态压缩·二
- [hihocoder]:1048 状态压缩二(状压DP)
- hihoCoder 1048 状态压缩·二
- 【HIHOCODER 1048】 状态压缩·二
- [hihocoder1048]状态压缩2
- hihocoder 1048:状态压缩·二
- 【状压DP】 ◆HihoCoder 1048◆ 状态压缩·二
- [HihoCoder]#1044 : 状态压缩·一
- hihocoder 1044 : 状态压缩·一
- HihoCoder 状态压缩一
- hihoCoder 1233 Boxes(状态压缩 + bfs)——ACM-ICPC国际大学生程序设计竞赛北京赛区(2015)网络赛
- hihoCoder#1048 状态压缩·二
- hihocoder 1044 状态压缩dp
- HihoCoder 1044 垃圾清理 (优化:状态压缩)
- hihoCoder 1044 : 状态压缩·一 状压dp
- hiho_1048_状态压缩2
- hihocoder-#1044 : 状态压缩·一
- HiHo #1048 : 状态压缩·二 【状压-.-类似省赛B题】