数字中不能出现4或者连续的62,数位DP裸题
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include<stdio.h>
2 #include<string.h>
3 long long ans;
4 bool a[1000000];
5 void fun(){
6 for(long long i=0;i<=1000000;i++){
7 bool f1=0,f2=1;
8 for(long long n=i;n>0;n/=10){
9 int a=n%10;
10 if((a==4)||(f1&&a==6)){
11 f2=0;
12 break;
13 }
14 else if(a==2){
15 f1=1;
16 }
17 else if(f1||a!=6){
18 f1=0;
19 }
20 }
21 if(f2)a[i]=1;
22 }
23
24 return;
25 }
26 int main(){
27 long long n,m;
28 memset(a,0,sizeof(a));
29 fun();
30 while(scanf("%I64d%I64d",&n,&m)!=EOF&&(n!=0||m!=0)){
31 ans=0;
32 for(long long i=n;i<=m;i++){
33 if(a[i])ans++;
34 }
35 printf("%I64d
",ans);
36 }
37 return 0;
38 }