博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ZOJ 3622 Magic Number 打表找规律
阅读量:4349 次
发布时间:2019-06-07

本文共 1697 字,大约阅读时间需要 5 分钟。

A - Magic Number

Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu

Submit
Appoint description:
 

Description

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 11 10

Sample Output

14 思路:首先我们得用数学方法推出 只要满足10^ans%a==0,就是magic数,ans指的是a这个数的位数 题解:找规律,然后人工打表……
#include 
#include
#include
using namespace std;int a1[10] = {
1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000};int a2[10] = {
2,20,200,2000,20000,200000,2000000,20000000,200000000,2000000000};int a3[10] = {
5,50,500,5000,50000,500000,5000000,50000000,500000000};int a4[10] = {
25,250,2500,25000,250000,2500000,25000000,250000000};int a5[10] = {
125,1250,12500,125000,1250000,12500000,125000000,1250000000};int main(){ int ans,n,m,i; while(~scanf("%d%d",&n,&m)) { ans = 0; if(n>m) swap(n,m); for(i = 0;i<10;i++) if(n<=a1[i] && a1[i]<=m) ans++; for(i = 0;i<10;i++) if(n<=a2[i] && a2[i]<=m) ans++; for(i = 0;i<9;i++) if(n<=a3[i] && a3[i]<=m) ans++; for(i = 0;i<8;i++) if(n<=a4[i] && a4[i]<=m) ans++; for(i = 0;i<8;i++) if(n<=a5[i] && a5[i]<=m) ans++; printf("%d\n",ans); } return 0;}

 

转载于:https://www.cnblogs.com/qscqesze/p/4316705.html

你可能感兴趣的文章
跑路啦 跑路啦 这个博客废掉啦
查看>>
JQuery 实现返回顶部效果
查看>>
辛苦挣钱买房,结果房产证一直办不下来
查看>>
Which kind of aspects of OIL PRESS MACHINERY would you like best
查看>>
[转载] 晓说——第17期:揭秘战争秘闻 朝鲜战争62年祭(下)
查看>>
java集合系列之ArrayList源码分析
查看>>
nyoj 518取球游戏(博弈)
查看>>
实验5
查看>>
luogu P1252 马拉松接力赛 P1803 凌乱的yyy / 线段覆盖
查看>>
11. 鼠标移到物体上高亮显示轮廓
查看>>
VS C++ DLL速度问题
查看>>
JavaScript弹出式日历控件 无jquery
查看>>
HTML5方向键控制会奔跑的马里奥大叔
查看>>
上周热点回顾(4.28-5.4)
查看>>
上周热点回顾(1.29-2.4)
查看>>
找到问题的真正原因:20121021服务器故障处理经历
查看>>
work of weekend 12/12/2015~12/14/2015
查看>>
命令行jarsigner签字和解决找不到证书链错误
查看>>
在学习ASP.NET中,GridView 控件的RowDataBound事件的使用详解
查看>>
Python实现与LeetCode--栈
查看>>