HDU2089[不要62]
来源:互联网 发布:window.open js 编辑:程序博客网 时间:2024/06/09 16:23
Description:
杭州人称那些傻乎乎粘嗒嗒的人为62(音:laoer)。
杭州交通管理局经常会扩充一些的士车牌照,新近出来一个好消息,以后上牌照,不再含有不吉利的数字了,这样一来,就可以消除个别的士司机和乘客的心理障碍,更安全地服务大众。
不吉利的数字为所有含有4或62的号码。例如:
62315 73418 88914
都属于不吉利号码。但是,61152虽然含有6和2,但不是62连号,所以不属于不吉利数字之列。
你的任务是,对于每次给出的一个牌照区间号,推断####出交管局今次又要实际上给多少辆新的士车上牌照了。
Input:
输入的都是整数对n、m(0
Output:
对于每个整数对,输出一个不含有不吉利数字的统计个数,该数值占一行位置。
Sample Input:
1 100
0 0
Sample Output:
80
解题思路:数位DP(模板题)
#include <cstdio>#include <cstring>#include <iostream>using namespace std;int a[20], dp[20][2];int dfs( int pos, int sta, bool lim ){ if ( pos < 0 ) return 1; if ( !lim && dp[pos][sta] != -1 ) return dp[pos][sta]; int up = lim ? a[pos] : 9, ret = 0; for (register int i = 0; i <= up; i++ ){ if ( sta && i == 2 || i == 4 ) continue; ret += dfs( pos-1, i == 6, lim && i == a[pos]); } if ( !lim ) dp[pos][sta] = ret; return ret;}int solve( int x ){ int pos = 0; for (; x; a[pos] = x % 10, x /= 10, pos++); return dfs( pos-1, 0, true);}int main(){ int l, r; memset( dp, -1, sizeof(dp)); while ( scanf( "%d%d", &l, &r)!= EOF && l + r ){ printf( "%d\n", solve(r) - solve(l-1) ); } return 0;}
阅读全文
0 0
- hdu2089 不要62
- hdu2089 不要62
- hdu2089 不要62
- 不要62(hdu2089)
- hdu2089不要62
- HDU2089 不要62
- hdu2089 不要62
- hdu2089 不要62
- hdu2089 不要62
- 不要62 hdu2089
- HDU2089:不要62
- 【HDU2089】【不要62】
- HDU2089不要62
- HDU2089不要62
- hdu2089不要62
- hdu2089 不要62
- hdu2089:不要62
- HDU2089-不要62
- JS之事件委托
- Apache安装错误 APR not found解决方法
- 互联网名词大全
- hdu 1010 Tempter of the Bone 简单带回溯的dfs+奇偶剪枝
- DFA算法的简单说明与案例实现
- HDU2089[不要62]
- 高中数学(理科思维)不是特别特别好,未来能做成优秀程序员吗?(转载)
- apt-get 使用详解
- Thinking in java个人笔记2
- BZOJ 2463 (博弈论)
- JS-Date对象
- HOG Matlab代码 2
- 整理并解释一些c++编译和运行错误
- ubuntu下编译QT6报缺少 libxcb 的处理方法