[ZOJ 3622] Magic Number
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 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 分析:
设y有k位数,则需要满足 (x*10^k+y)%y==0
--> (x*10^k%y+0)%y==0
--> x*10^k%y==0
--> 由于x是任意的,假设x为质数,则需要满足(10^k)%y==0
直接判断会超时,先打表。
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
#define N 100010 int n,m;
int len;
int num[N]=
{,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
}; int main()
{
while(scanf("%d%d",&m,&n)!=EOF)
{
if(m>n) swap(m,n);
int cnt=;
for(int i=;i<;i++)
{
if(m<=num[i] && num[i]<=n) cnt++;
}
cout<<cnt<<endl;
}
return ;
}
[ZOJ 3622] Magic Number的更多相关文章
- ZOJ 3622 Magic Number 打表找规律
A - Magic Number Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Subm ...
- ZOJ 3622 Magic Number(数)
题意 假设一个正整数y满足 将随意正整数x放到y的左边得到的数z满足 z%y==0 那么这个数就是个Magic Number 给你一个范围 求这个范围内Magic Number的个数 令 ...
- ZOJ 2477 Magic Cube(魔方)
ZOJ 2477 Magic Cube(魔方) Time Limit: 2 Seconds Memory Limit: 65536 KB This is a very popular gam ...
- 一个快速double转int的方法(利用magic number)
代码: int i = *reinterpret_cast<int*>(&(d += 6755399441055744.0)); 知识点: 1.reinterpret_cast&l ...
- Magic Number(Levenshtein distance算法)
Magic Number Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit ...
- LVM XFS增加硬盘分区容量(resize2fs: Bad magic number in super-block while)
LVM XFS增加硬盘分区容量(resize2fs: Bad magic number -- :: 分类: Linux LVM XFS增加硬盘分区容量(resize2fs: Bad magic num ...
- poj magic number
Problem H Time Limit : 4000/2000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Total Sub ...
- iOS Exception Code 之 Magic Number
https://en.wikipedia.org/wiki/Hexspeak iOS Exception Code 之 Magic Number 备忘.
- Magic Number (zoj3622)
Magic Number (zoj3622) Time Limit : 4000/2000ms (Java/Other) Memory Limit : 65536/32768K (Java/Oth ...
随机推荐
- js页面之间函数调用
1.在父级页面调用子级页面的函数 当前页面(default.aspx)通过iframe嵌套index.aspx页面,在当前页面调用index.aspx里面的js函数,如下: myFrame.windo ...
- BigInteger构造函数解析
1.BigInteger(byte[] val)这个构造函数用于转换一个字节数组包含BigInteger的二进制补码,以二进制表示成一个BigInteger. (用字节数组中值的ASCII码构造Big ...
- ASP.NET页面生命周期总结(2)
HttpAplicationFactory获取一个HttpApplication对象: 内部:1.如果是第一次请求过来,那么就把global文件编译成一个类型.(后续请求来的,就可以直接获取这个类型) ...
- UIView转场动画属性设置
常规动画属性设置(可以同时选择多个进行设置) UIViewAnimationOptionLayoutSubviews:动画过程中保证子视图跟随运动. UIViewAnimationOptionAllo ...
- 动态加载js、css 代码
一.原生js: /** * 加载js和css文件 * @param jsonData.path 前缀路径 * @param jsonData.url 需要加载的js路径或css路径 * @param ...
- 网卡添加VLAN TAG
#modprobe 8021q 用命令 lsmod | grep 8021q 来检查 以配置网卡eth0为例,添加vlan号:1002 ================================ ...
- 网站开发常用jQuery插件总结(13)定位插件scrollto
一.scrollto插件功能 scrollto用于定位页面中元素的位置,并使滚动条滚动到当前元素. 二.scrollto官方地址 https://github.com/flesler/jquery.s ...
- javascript 老王开车去东北
[Decode error - output not utf-8] 魔女 飞 奔驰 去 华南 [Finished in 1.1s] 需要变化的对象进行隔离.正是编程的乐趣之处 /** * by Jac ...
- Linux下使用openvpn客户端
安装 root 权限用户下 :yum install openvpn fedora23的yum可能会切换到dnf源上安装不必在意,等待就ok. 稍等片刻将自动安装好openvpn需要的软件包.安装完成 ...
- 用javascript操作xml(三)关于Jquery的html()不兼容IE的解决办法
当 $("#xxx").html(data); 不兼容,方法替换为 document.getElementById("xxx").innerHTML=data;