A positive number y is called magic number if for every positive integer x it satisfies that put y to the right of x, which will form a new integer z, z mod y = 0.
Input
The input has multiple cases, each case contains two positve integers m, n(1 <= m <= n <= 2^31-1), proceed to the end of file.
Output
For each case, output the total number of magic numbers between m and n(m, n inclusively).
Sample Input
1 1 1 10
Sample Output
1 4
思路:直接打表就可以得到结果,水题。
AC代码如下;
#include<cstdio>
#include<cstring>
using namespace std;
long long num[100],m,n;
int main()
{ int i,j,k;
num[1]=1;
num[2]=2;
num[3]=5;
num[4]=10;
num[5]=20;
num[6]=25;
num[7]=50;
num[8]=100;
num[9]=125;
num[10]=200;
num[11]=250;
num[12]=500;
for(i=13;i<=52;i++)
num[i]=num[i-5]*10;
while(~scanf("%lld%lld",&m,&n))
{ k=0;
for(i=1;i<=52;i++)
if(m<=num[i] && num[i]<=n)
k++;
printf("%d\n",k);
}
}

326

被折叠的 条评论
为什么被折叠?



