Magic Number - ZOJ 3622 水题

23 篇文章 1 订阅

Magic Number

Time Limit: 2 Seconds       Memory Limit: 32768 KB

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 zz mod y = 0.

Input

The input has multiple cases, each case contains two positve integers mn(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(mn 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);
  }
}




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值