HDU 2089_不要62
来源:互联网 发布:手机免费sip软件 编辑:程序博客网 时间:2024/06/18 10:07
数位dp:
代码:
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;
int f[15][2], bit[15];
int dfs(int p, int s, int e) {
if (p == -1) {
return 1;
}
if (!e && ~f[p][s]) return f[p][s];
int res = 0;
int u = e ? bit[p] : 9;
for (int i = 0; i <= u; ++i) {
if(i==4||(i==2&&s)) {
continue;
}
res += dfs(p-1,i==6, e&&i==u);
}
return e ? res : f[p][s] = res;
}
int cal(int x) {
int idx = 0;
while (x) {
bit[idx++] = x % 10;
x /= 10;
}
return dfs(idx-1, 0, 1);
}
int main() {
int T, l, r;
memset(f, 0xff, sizeof (f));
while (scanf("%d %d", &l, &r)) {
if(r==0&&l==0) {
break;
}
printf("%d\n", cal(r) - cal(l-1));
// for (int i = 0; i < 10; ++i) {
// printf("%d ", f[i][3]);
// }
// puts("");
}
return 0;
}
- HDU 2089_不要62
- hdu 2089 不要62
- hdu 2089 不要62
- hdu 2089 不要62
- HDU 2089 不要62
- HDU 2089 不要62
- HDU 2089 不要62
- hdu 2089 不要62
- hdu 2089 不要62
- hdu 2089 不要62
- hdu 2089 不要62
- HDU:2089 不要62
- hdu 2089 不要62
- hdu 2089 不要62
- hdu 2089 不要62
- hdu 2089 不要62
- HDU 2089 不要62
- hdu 2089 不要62
- SQL Server 2005/2008 触发器的管理和查看
- grr google
- 真正的免费wifi是哪种,从哪里看门道?
- CPU对内存管理二
- 交换函数Exchanger的使用
- HDU 2089_不要62
- 程序开始
- unity中camera怎么生成使用深度图 Camera Depth Texture 实现Image Effect
- 下机——观察者模式
- Chromium的沙盒Sandbox
- C++中强制类型转换 static_cast、dynamic_cast 区别(转载)
- mysql 获取本周 本月所属数据
- uva 10588 - Queuing at the doctors(优先队列)
- 根据两点经纬度计算距离 附C#和PHP代码