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的更多相关文章

  1. ZOJ 3622 Magic Number 打表找规律

    A - Magic Number Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Subm ...

  2. ZOJ 3622 Magic Number(数)

    题意  假设一个正整数y满足  将随意正整数x放到y的左边得到的数z满足 z%y==0  那么这个数就是个Magic Number   给你一个范围  求这个范围内Magic Number的个数 令 ...

  3. ZOJ 2477 Magic Cube(魔方)

    ZOJ 2477 Magic Cube(魔方) Time Limit: 2 Seconds      Memory Limit: 65536 KB This is a very popular gam ...

  4. 一个快速double转int的方法(利用magic number)

    代码: int i = *reinterpret_cast<int*>(&(d += 6755399441055744.0)); 知识点: 1.reinterpret_cast&l ...

  5. Magic Number(Levenshtein distance算法)

    Magic Number Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit ...

  6. LVM XFS增加硬盘分区容量(resize2fs: Bad magic number in super-block while)

    LVM XFS增加硬盘分区容量(resize2fs: Bad magic number -- :: 分类: Linux LVM XFS增加硬盘分区容量(resize2fs: Bad magic num ...

  7. poj magic number

    Problem H Time Limit : 4000/2000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Sub ...

  8. iOS Exception Code 之 Magic Number

    https://en.wikipedia.org/wiki/Hexspeak  iOS Exception Code 之 Magic Number 备忘.

  9. Magic Number (zoj3622)

    Magic Number (zoj3622) Time Limit : 4000/2000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Oth ...

随机推荐

  1. VC中动态添加控件

    VC中动态添加控件 动态控件是指在需要时由Create()创建的控件,这与预先在对话框中放置的控件是不同的. 一.创建动态控件: 为了对照,我们先来看一下静态控件的创建. 放置静态控件时必须先建立一个 ...

  2. ios应用来电监听

    先导入这两个头文件,库文件不用导可以 #import <CoreTelephony/CTCallCenter.h> #import <CoreTelephony/CTCall.h&g ...

  3. iOS开发——TTS文本发音

    iOS的文本转发音,从iOS7开始,iOS系统自带这个功能.能够实现中文.英文的发音.而且实现的起来非常方便.就像我看到有的博主说的三行代码搞定. (在iOS7之前(目前已不适配了),比如iOS6实现 ...

  4. 初识CoreText

    一.基本知识介绍 1.字符(Character)和字形(Glyphs) 排版系统中文本显示的一个重要的过程就是字符到字形的转换,字符是信息本身的元素,而字形是字符的图形表征,字符还会有其它表征比如发音 ...

  5. Android版多线程下载器核心代码分享

    首先给大家分享多线程下载核心类: package com.example.urltest; import java.io.IOException; import java.io.InputStream ...

  6. 检测 IE 版本 in Javascript

    点击打开链接http://stackoverflow.com/questions/10964966/detect-ie-version-in-javascript <!doctype html& ...

  7. [C#]async/Await 使用小计

    如果指定使用 异步 或 异步 修饰符,方法是异步方法,可以实现以下两个函数.  • 清单异步方法可以使用 Await 或指定的 等待 悬挂点.  等待运算符通知编译器异步方法不能继续点的过去,直到等待 ...

  8. [C#]『PLINQ』任务并行库使用小计

    并行 LINQ (PLINQ) 是 LINQ to Objects 的并行实现. PLINQ 实现完整的 LINQ 标准查询运算符集作为 T:System.Linq 命名空间的扩展方法,并具有用于并行 ...

  9. MySQL中EXPLAIN解释命令详解

    MySQL中的explain命令显示了mysql如何使用索引来处理select语句以及连接表.explain显示的信息可以帮助选择更好的索引和写出更优化的查询语句. 1.EXPLAIN的使用方法:在s ...

  10. python实现模拟登录【转】

    原文网址:http://www.blogjava.net/hongqiang/archive/2012/08/01/384552.html 本文主要用python实现了对网站的模拟登录.通过自己构造p ...