不要62
来源:互联网 发布:舰娘重巡数据 编辑:程序博客网 时间:2024/05/22 06:13
题目链接
- 题意:
求出a到b之间 1)不含有连续的62 2)不含有4
的数的个数 - 分析:
两种状态,记录62。4直接判断即可
LL f[100][2], bits[100];LL dfs(int pos, int s, bool lmt){ if (pos == -1) return 1; if (!lmt && ~f[pos][s]) return f[pos][s]; int u = lmt ? bits[pos] : 9; LL ret = 0; for (int i = 0; i <= u; i++) { if ((s == 1 && i == 2) || i == 4) continue; int nxt = 0; if (i == 6) nxt = 1; ret += dfs(pos - 1, nxt, lmt && i == u); } return lmt ? ret : f[pos][s] = ret;}LL calc(LL n){ CLR(f, -1); LL len = 0; while (n) { bits[len++] = n % 10; n /= 10; } return dfs(len - 1, 0, true);}int main(){ //freopen("0.txt", "r", stdin); LL a, b; while (cin >> a >> b && a) cout << calc(b) - calc(a - 1) << endl; return 0;}
1 0
- 不要62
- 不要62
- 不要62
- 不要62
- 不要62
- 不要62
- 不要62
- 不要62
- 不要62
- 不要62
- 不要62
- 不要62
- 不要62
- 不要62
- 不要62
- 不要62
- 不要62
- 不要62
- linux 守护进程编写
- printf格式输出数字,位数不够前面补0,适用与输出编号
- DataTable数据转换为实体
- Google Play商店成Google第二大营收渠道
- 细说php(二) 变量和常量
- 不要62
- CComModule类
- SVN快捷临时解决问题 (如报 svn: Checksum mismatch while updating ..... )
- poj3041 Asteroids --- 最小点覆盖
- Floodlight Controller 路由原理
- 小结:VB.NET机房收费系统个人版
- cocos2d-x中的plist文件格式详解
- Intent可以传递的数据类型
- fafu 1453 DNA排序