【数学规律】-ZOJ-3622-Magic Number
2014-06-30 08:41
197 查看
题目链接: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截图:
题目描述:找这样的数 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截图:
相关文章推荐
- zoj 3622 Magic Number(找规律)
- zoj 3622 Magic Number 【规律】
- ZOJ 3622 Magic Number 打表找规律
- zoj 3622 Magic Number (找规律+打表)
- ZOJ-#3622 Magic Number(找规律)
- ZOJ 3622 Magic Number(数)
- Magic Number - ZOJ 3622 水题
- ZOJ 3622 Magic Number(数)
- 【数学规律】-ZOJ-3629-Treasure Hunt IV
- zoj 3622 Magic Number
- ZOJ 3622 —— Magic Number(水题)
- ZOJ 3622 Magic Number
- zoj 3872 (一切找规律都是基于数学!)
- zoj 2060 Fibonacci Again(fibonacci数列规律、整除3的数学特性)
- zoj 3622 Magic Number
- zoj 3622 Magic Number (构造?)
- ZOJ3872 Beauty of Array---规律 | DP| 数学能力
- ZOJ 3622 Magic Number(打表)
- zoj 3622 Magic Number
- [ZOJ 3622] Magic Number