描述
Mostrp是个爱干净的好少年。 有一次去澡堂洗澡时发现 澡堂的澡柜编号中没有出现过数字‘4’。 Mostrp 感到很好奇。可能是因为在澡堂老板眼里。数字‘4’是十分不吉利的。
现在Mostrp知道澡柜的最大的编号N,你能帮他算出澡堂一共有多少澡柜吗?
-
输入
- 有多组数据,每行输入一个N。
( 1 <= N <= 50000 )
输出 - 输出澡柜的个数,输出占一行。 样例输入
-
3 5
样例输出 -
3 4
#include<stdio.h>
#include<stdlib.h>
int main()
{
int n,t,i,j,a[10],s;
while(~scanf("%d",&n))
{
i=0;
while(n)
{
t=n%10;
n/=10;
a[i++]=t;
if(t>=4)
a[i-1]--;
}
s=0;
for(j=i-1; j>0; j--)
s=(s+a[j])*9;
s+=a[0];
printf("%d\n",s);
}
return 0;
}