标签:des style http io color ar os java for
1 100 0 0
80
#include<algorithm>
#include<iostream>
#include<string.h>
#include<stdio.h>
using namespace std;
const int INF=0x3f3f3f3f;
const int maxn=100010;
typedef long long ll;
int dp[10][15],num[10];
void init()
{
for(int i=0;i<10;i++)
dp[1][i]=1;
for(int i=2;i<=7;i++)
for(int j=0;j<10;j++)
for(int k=0;k<10;k++)
if((j!=6||k!=2)&&k!=4)
dp[i][j]+=dp[i-1][k];
}
int calc(int x)
{
int ct=0,ans=0,i,j;
while(x)
{
num[ct++]=x%10;
x/=10;
}
for(i=ct-1;i>=1;i--)//处理长度小于ct的
for(j=1;j<10;j++)
if(j!=4)
ans+=dp[i][j];
for(i=num[ct-1]-1;i>0;i--)
if(i!=4)
ans+=dp[ct][i];
for(i=ct-2;i>=0;i--)
{
if(num[i+1]==4)
break;
for(j=num[i]-1;j>=0;j--)
if((num[i+1]!=6||j!=2)&&j!=4)
ans+=dp[i+1][j];
if(num[i+1]==6&&num[i]==2)//開始写掉了
break;
}
return ans;
}
int main()
{
int n,m;
init();
while(scanf("%d%d",&n,&m),n||m)
printf("%d\n",calc(m+1)-calc(n));
return 0;
}
标签:des style http io color ar os java for
原文地址:http://www.cnblogs.com/bhlsheji/p/4074178.html