hdu 2089——不要62
来源:互联网 发布:剑3少林捏脸数据 编辑:程序博客网 时间:2024/04/28 03:33
题意:
就是求出来一个数段中不含有62的数的数量有多少?
和之前的一道题差不多,就是稍微改了一下条件就好了。
#include<cstdio>#include<cstring>#include<map>#include<set>#include<cmath>#include<algorithm>#include<vector>#include<queue>#include<iostream>#include<time.h>using namespace std;typedef __int64 ll;typedef unsigned __int64 ULL;#define pi acos(-1.0)#define Ex exp(1.0)#define maxn 10int dig[maxn],vis[maxn][maxn];ll dp[maxn][maxn];ll go(int dep,int pre,int less){if(dep<0) return 1;else if(vis[dep][pre]&&less) return dp[dep][pre];else{if(less){ll& tmp=dp[dep][pre];vis[dep][pre]=1;for(int i=0;i<10;i++){if(i!=4){//注意这里是i!=4if(pre!=6||(pre==6&&i!=2)){tmp+=go(dep-1,i,1);}}}return tmp;}else{ll tmp=0;for(int i=0;i<=dig[dep];i++){if(i!=4){if(pre!=6||(pre==6&&i!=2)){tmp+=go(dep-1,i,i!=dig[dep]);}}}return tmp;}}}ll solve(ll x){int len=0;if(x==0) return 1;while(x){dig[len++]=x%10;x=x/10;}return go(len-1,0,0);}int main(){ll n,m;while(~scanf("%I64d%I64d",&n,&m)){if(n==0&&m==0) break;if(n>m) swap(n,m);printf("%I64d\n",solve(m)-solve(n-1));}#ifndef ONLINE_JUDGEsystem("pause");#endifreturn 0;}/*1 1000 0 */
0 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
- 在Docker容器中创建OpenVPN时的最小权限的开启方法
- JMeter数据库请求配置及示例
- 左右滑动的Tab
- maven 简介
- CDN
- hdu 2089——不要62
- runtime - 运行时机制1
- Java面向对象编程
- 【SPOJ-COINS】Bytelandian gold coins【DP】
- Android的快速开发框架 afinal
- 【SQL Server】Session blocking
- zstu 2545 地道战
- JAVA_继承演示04_FoodManagerDeamo.java____super关键字____冒泡排序
- Android studio 修改项目列表的字体大小