nyoj-506-洗澡

 1 #include<stdio.h>
 2 #include<algorithm>
 3 #include<functional>
 4 #include<string.h>
 5 using namespace std;
 6 int main()
 7 {
 8     int n,i,s[50010];
 9     s[0]=0;
10     for(i=1;i<=50000;i++)//采用暴力打表法,将所有的结果直接打表
11     {
12         int a,b,c,d,e;
13         a=i/10000;
14         b=i%10000/1000;
15         c=i%1000/100;
16         d=i%100/10;
17         e=i%10;
18         if(a==4||b==4||c==4||d==4||e==4)
19         s[i]=s[i-1];
20         else
21         s[i]=s[i-1]+1;
22     }
23     while(scanf("%d",&n)!=EOF)
24     {
25         printf("%d\n",s[n]);
26     }
27     return 0;
28 }

 

posted @ 2013-07-07 17:29  nylg-haozi  阅读(145)  评论(0编辑  收藏  举报