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

令 l表示y的位数  ly=10^l  那么z=x*ly + y  要z%y==0   easy看出  仅仅需 x*ly%y==0

又由于x是随意的  所以一个Magic Number必须满足 ly%y==0

y<2^31  所以l最大为10 直接枚举l  找到全部符合的y即可了

当 ly%y==0
 时  y>=ly/10&&y<ly  即ly是比y多一位数的 令t=ly/y
 那么肯定有 1<t<=10  对于每一个ly  我们就仅仅用枚举t了

#include<cstdio>
#include<algorithm>
using namespace std;
const int N = 50;
typedef long long ll;
ll p[N], n, m; int main()
{
int cnt = 0, ans; //ly为10^l
for(ll ly = 10; ly < 1e11; ly *= 10)
{
for(ll t = 10; t > 1; --t) //若(ly/y==t) 必有1<t<=10
if(ly % t == 0) p[cnt++] = ly / t;
} while(~scanf("%lld%lld", &n, &m))
{
ans = upper_bound(p, p + cnt, m) - lower_bound(p, p + cnt, n);
printf("%d\n", ans);
}
return 0;
}

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 zz mod y =
0.

Input

The input has multiple cases, each case contains two positve integers mn(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(mn inclusively).

Sample Input

1 1
1 10

Sample Output

1
4

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

    Magic Number Time Limit: 2 Seconds      Memory Limit: 32768 KB A positive number y is called magic n ...

  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. poj magic number

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

  6. 幻数浅析(Magic Number)

    在源代码编写中,有这么一种情况:编码者在写源代码的时候,使用了一个数字,比如0x2123,0.021f等,他当时是明白这个数字的意思的,但是别的程序员看他的代码,可能很难理解,甚至,过了一段时间,代码 ...

  7. Magic Number(Levenshtein distance算法)

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

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

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

  9. iOS Exception Code 之 Magic Number

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

随机推荐

  1. Chukwa

    http://baidutech.blog.51cto.com/4114344/748261/ http://blog.csdn.net/cnbird2008/article/details/1451 ...

  2. known good die( KGD) /确认好裸芯片,合格芯片

    英文:known good die( KGD) / 中文:确认好裸芯片,合格芯片 完工的晶圆上有许多晶片存在,其单一品质有好有坏,经过老化试验后,其确知电性能良好的晶片即称为己知好晶片.不过,已知好晶 ...

  3. SPI通信

    SPI是由Motorola公司提出的一种同步串行外围接口:它在速度要求不高,低功耗,需要保存少量参数的智能化传感系统中得到了广泛应用: SPI是一个全双工的同步串行接口,在数据传输过程中,总线上只能是 ...

  4. Android:ServiceDemo

    效果图: layout的main.xml: <?xml version="1.0" encoding="utf-8"?> <LinearLay ...

  5. Javascript DOM 03 表格添加、删除 + 搜索

    获取 tBodies.tHead.tFoot.rows.cells   隔行变色 鼠标移入高亮   添加.删除一行 DOM方法的使用                                   ...

  6. CentOS 6 用SVN自动提交文件到web服务器

    关于 svn 的安装 参考:[转]Linux(centOS6.5)下SVN的安装.配置及开机启动 经过两天的各种尝试总算解决了,总结如下: 1.在建立库时注意 要让库的名称和  要同步的 web目录名 ...

  7. 我的Python成长之路---GitHub使用之注册GitHub并安装Git客户端

    一.注册GitHub账号 进入GitHub官方网站,输入用户名.邮箱地址及密码,点击“Sign up for GitHub”. 选择免费的,不要问我为什么,除非有钱任性选择付费版 验证邮箱地址并激活G ...

  8. ecshop后台添加栏目

    ecshop后台增加模块菜单详细教程 一:ecshop后台管理 admin\includes\inc_menu.php 添加上你要添加的功能admin\includes\inc_priv.php 对应 ...

  9. iOS开发UITableViewCell的选中时的颜色设置

    1.系统默认的颜色设置 //无色 cell.selectionStyle = UITableViewCellSelectionStyleNone; //蓝色 cell.selectionStyle = ...

  10. 详解iOS7升级细节:引领视觉革命

    下星期我们将看到的正式版将和WWDC上看到的大不相同.苹果六月份发布了全新版本的iOS操作系统——这是从2007年首次发布以来的最大的一次调整和改进.这次的改变招致许多批评.许多设计师在网站上晒出了他 ...