HDOJ 2089 不要62
来源:互联网 发布:mac os系统dmg镜像 编辑:程序博客网 时间:2024/05/17 02:50
超级简单的数位DP....
不要62
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 17584 Accepted Submission(s): 5800
Problem Description
杭州人称那些傻乎乎粘嗒嗒的人为62(音:laoer)。
杭州交通管理局经常会扩充一些的士车牌照,新近出来一个好消息,以后上牌照,不再含有不吉利的数字了,这样一来,就可以消除个别的士司机和乘客的心理障碍,更安全地服务大众。
不吉利的数字为所有含有4或62的号码。例如:
62315 73418 88914
都属于不吉利号码。但是,61152虽然含有6和2,但不是62连号,所以不属于不吉利数字之列。
你的任务是,对于每次给出的一个牌照区间号,推断出交管局今次又要实际上给多少辆新的士车上牌照了。
杭州交通管理局经常会扩充一些的士车牌照,新近出来一个好消息,以后上牌照,不再含有不吉利的数字了,这样一来,就可以消除个别的士司机和乘客的心理障碍,更安全地服务大众。
不吉利的数字为所有含有4或62的号码。例如:
62315 73418 88914
都属于不吉利号码。但是,61152虽然含有6和2,但不是62连号,所以不属于不吉利数字之列。
你的任务是,对于每次给出的一个牌照区间号,推断出交管局今次又要实际上给多少辆新的士车上牌照了。
Input
输入的都是整数对n、m(0<n≤m<1000000),如果遇到都是0的整数对,则输入结束。
Output
对于每个整数对,输出一个不含有不吉利数字的统计个数,该数值占一行位置。
Sample Input
1 1000 0
Sample Output
80
Author
qianneng
Source
迎接新学期——超级Easy版热身赛
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;const int maxn=1000010;int dp[8][3];int bit[8];int dfs(int pos,int s,int limit){ if(pos==-1) return s==0||s==1;///目标状态 if(!limit&&dp[pos][s]!=-1) return dp[pos][s]; int end=limit?bit[pos]:9; int ans=0; for(int i=0;i<=end;i++) { int news=0; if(i==4) news=2; if(i==2&&s==1) news=2; if(i==6) news=1; if(s==2) news=2; ans+=dfs(pos-1,news,limit&&i==end); } if(!limit) dp[pos][s]=ans; return ans;}int solve(int x){ int pos=0; while(x) { bit[pos++]=x%10; x/=10; } return dfs(pos-1,0,1);}int main(){ memset(dp,-1,sizeof(dp)); int n,m;while(scanf("%d%d",&n,&m)!=EOF){ if(n==0&&m==0) break; printf("%d\n",solve(m)-solve(n-1));} return 0;}
2 0
- HDOJ 2089 不要62
- HDOJ 2089 不要62
- hdoj 2089 不要62
- HDOJ 2089 不要62
- 不要62 hdoj 2089
- HDOJ 2089 不要62
- HDOJ 2089 不要62
- hdoj 2089 不要62
- HDOJ 2089 不要62
- 【HDOJ 2089】不要62
- HDOJ--2089--不要62
- hdoj-2089-不要62
- HDOJ-2089 不要62
- HDOJ 2089 不要62
- hdoj 2089 不要62
- HDOJ 2089 不要62
- hdoj-【2089 不要62】
- HDOJ.2089 不要62
- 关于strtok函数【转】
- 迭代器模式
- 函数指针例子
- as编写hello,world
- Linux shell脚本(2)
- HDOJ 2089 不要62
- leetcode第一刷_Sum Root to Leaf Numbers
- Java编程思想摘录--第1章 对象入门
- 泡过的茶叶有何用途
- uva673
- NYOJ58-最少步数
- Boa的移植过程
- 第10周工作总结与计划
- 键盘钩子