标签:tom creat 消息 output style can mis amp out
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 36862 Accepted Submission(s): 13418
Input
Output
Sample Input
Sample Output
// // main.cpp // hdu2089 // // Created by Candy on 13/11/2016. // Copyright © 2016 Candy. All rights reserved. // #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> using namespace std; typedef long long ll; const int N=10; int l,r; int d[N][4]; void dp(){ d[0][0]=1; for(int i=1;i<=6;i++){ d[i][0]=9*d[i-1][0]-d[i-1][1]; d[i][1]=d[i-1][0]; d[i][2]=10*d[i-1][2]+d[i-1][1]+d[i-1][0]; } } int a[N]; int sol(int n){ int len=0,tn=n,ans=0; while(n) a[++len]=n%10,n/=10; a[len+1]=0; int flag=0; for(int i=len;i>=1;i--){ ans+=d[i-1][2]*a[i]; if(flag) ans+=a[i]*d[i-1][0]; //begin skyline else{ if(a[i]>4) ans+=d[i-1][0];//maybe 4 if(a[i+1]==6&&a[i]>2) ans+=d[i][1];//maybe 62 if(a[i]>6) ans+=d[i-1][1];//maybe 62 } if(a[i]==4||(a[i+1]==6&&a[i]==2)) flag=1;//has unlucky } return tn-ans; } int main(int argc, const char * argv[]) { dp(); while(scanf("%d%d",&l,&r)&&l+r) printf("%d\n",sol(r+1)-sol(l)); return 0; }
标签:tom creat 消息 output style can mis amp out
原文地址:http://www.cnblogs.com/candy99/p/6060444.html