【数学规律】-ZOJ-3622-Magic Number

题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3622

题目描述:找这样的数 y 。把 y 放在任意一个自然数的右侧,构成的新数能被 y 整除。

解题思路:

想一下~

一位数: 1 ,2 ,5

两位数: 10, 20, 50, 25

三位数: 100, 200, 500, 250 ,125

四位数: 1000, 2000, 5000, 2500 ,1250

没错,就是这样,依次类推到九位数就够用了,手工写个表就过了。。差点就能抢到一血了,,唉

AC代码:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int arr[45] = {
10,
1,
2,
5,
100,
20,
50,
25,
1000,
200,
500,
250,
125,
10000,
2000,
5000,
2500,
1250,
100000,
20000,
50000,
25000,
12500,
1000000,
200000,
500000,
250000,
125000,
10000000,
2000000,
5000000,
2500000,
1250000,
100000000,
20000000,
50000000,
25000000,
12500000,
1000000000,
200000000,
500000000,
250000000,
125000000,
2000000000,
1250000000
};

int main()
{
    //freopen("input.txt","r",stdin);
    int m,n,i;
    while(cin>>m>>n)
    {
        int ans=0;
        for(i=0;i<45;i++)
            if(arr[i]>=m && arr[i]<=n) ans++;
        cout<<ans<<endl;
    }
    return 0;
}

AC截图:




  

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值