摘要: 题意:求n到m中有多少个数不含“4”和“62”View Code #include <stdio.h>#include <string.h>#define LEN 10char a[LEN],b[LEN];int n,m;int dp[LEN][3][2];int nextstate(int cur,int in){ if(cur==2 || cur==1&&in==2 || in==4) return 2; return in==6;}int nextflag(int cur,int in,int max){ if(cur==1 && 阅读全文
posted @ 2012-08-01 23:53 BeatLJ 阅读(468) 评论(0) 推荐(0) 编辑
摘要: 题目大意:求1到n中有多少个数含“49”第一次接触按位DP,参考了别人的题解。第一个代码运行速度快些(31ms),但状态的转移的分析比较麻烦,第二个代码要慢些(125ms),但code比较方便。View Code #include <stdio.h>#include <string.h>#define LEN 22typedef __int64 LL;char s[LEN];LL dp[LEN][3][2];int next(int cur,int in){ if(cur==2 || cur==1&&in==9) return 2; return in= 阅读全文
posted @ 2012-08-01 23:48 BeatLJ 阅读(212) 评论(0) 推荐(0) 编辑
摘要: 题目大意:给一个n*m的方格地图,每个方格中有一个字符,'.'草地,'*'泥巴地,给你一些宽为1方格大小的板子,长度不限,问最少需要多少板子才能盖住所有的泥巴地,但是不能盖住草地,板子允许相互覆盖。分析:扫描行,将连通的泥巴地看成一个结点,这样得到二分图的X部,按同样的方法扫描列得到二分图的Y部,有公共方格的结点之间连边。View Code #include <stdio.h>#include <string.h>#define N 51#define M 51char map[N][M];bool g[N*M][N*M];int n,m 阅读全文
posted @ 2012-08-01 17:19 BeatLJ 阅读(252) 评论(0) 推荐(0) 编辑