Problem H

Time Limit : 4000/2000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 24   Accepted Submission(s) : 8
Problem 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. 1 1
  2. 1 10

Sample Output

  1. 1
  2. 4
    怎样打表
    这些数都是有规律的从100开始后面都只是加了个0而已,所以可以很快找出来。pow2,31)=2147483648
  1. #include<stdio.h>
  2. #include<math.h>
  3. int main()
  4. {
  5. long long int a[]={,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, , , ,, , , , ,, , ,, ,, };
  6. long long m,n,i,t;//不能用I64,wa了用long long,而且vc编译器是非法的。
  7. while(~scanf("%lld%lld",&m,&n))
  8. {
  9. t=;
  10. for(i=;i<;i++)
  11. {
  12. if(a[i]>=m&&a[i]<=n)
  13. t++;
  14. if(a[i]>n)
  15. break;
  16. }
  17. printf("%lld\n",t);
  18. }
  19. return ;
  20. }

把数组的那些数是怎样弄出来的代码:

  1. #include<stdio.h>
  2. #include<math.h>
  3. int main()
  4. {
  5. __int64 x,y,t=,m,k;
  6. while(scanf("%I64d%I64d",&x,&y)!=EOF)
  7. {
  8. int i,j;
  9. k=;
  10. for(i=;i<pow(,);i++)
  11. {
  12. t=;
  13. m=i;
  14. while(m)
  15. {
  16. t++;m/=;
  17. }
  18. int p=;
  19. for(j=;j<=i;j++)
  20. {
  21. if((j*(__int64)pow(,t))%i)
  22. {
  23. p=;
  24. break;
  25. }
  26. }
  27. if(p)
  28. {
  29. printf("%I64d ",i);
  30. }
  31. }
  32. printf("\n");
  33. }
  34. return ;
  35. }

poj magic number的更多相关文章

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

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

  2. Magic Number(Levenshtein distance算法)

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

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

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

  4. [ZOJ 3622] Magic Number

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

  5. ZOJ 3622 Magic Number(数)

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

  6. iOS Exception Code 之 Magic Number

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

  7. Magic Number (zoj3622)

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

  8. ZOJ 3622 Magic Number 打表找规律

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

  9. resize2fs: Bad magic number in super-block while trying to open

    I am trying to resize a logical volume on CentOS7 but am running into the following error: resize2fs ...

随机推荐

  1. 在类成员函数后面加const

    在看开源代码时,经常会看到在类的成员函数后面加const,之前了没有太关注过,近来闲来无事,就想起这件事,网上查了一下,大概明白了是怎么回事,这里引用CSDN愽文里的段话:“编译器会自动给每一个函数加 ...

  2. ARM 平台上的Linux系统启动流程

    开始学习嵌入式开发就一直在使用Linux系统作为学习的平台,到现在无论是PC机还是ARM开发板都已经能顺利地跑起了Linux系统,但是对Linux 的启动流程还是不甚了解.于是开始各种百度谷歌,当然看 ...

  3. 【原创】QT编程 多线程

    请先保证已安装QT,没有请参考 http://www.cnblogs.com/kavs/p/4608926.html  安装QT. 新建threads文件夹存放项目:mkdir threads sud ...

  4. a标签使用

    1.发起邮件 注意:如果mailto后面同时有多个参数的话,第一个参数必须以“?”开头,后面的参数每一个都以“&”分隔. <a href="mailto:281345774@q ...

  5. 移动端开发(使用webuploader上传图片,客户端交互,修改alert弹窗等)

    之前实习做的一个移动端的页面 需要的功能有图片上传 点击客户端的返回按钮 有提示(即与客户端有交互) 遇到不少的坑 总结一下问题 1.图片上传功能  使用工具 百度的webuploader 暂时遇到的 ...

  6. PDO操作mysql数据库(二)

    从 MySQL 数据库读取数据 <?php $server = "localhost"; $user = "root"; $pwd = "123 ...

  7. 跨域、sql注入、xss攻击

    这几天遇到这三个问题,现在简单的记录下来. 1.跨域 如我服务器的域名是www.test1.com,我在另一个服务器www.test2.com通过ajax访问www.test1.com的数据时,就引起 ...

  8. [转]ef获取某个表中的部分字段值

    我有个新闻表 id,title,body,createtime,author,click 使用ef4.1 仅仅读取 id,title,createtime 并显示在页面上. public static ...

  9. 查看sqlserver数据库的端口号

    最近正在用sqlserver作为java的数据库进行开发,在写连接字符串的时候,想起一个问题,怎么查找sqlserver的端口号呢?有两种方法 1,用存储过程 --查询端口号exec sys.sp_r ...

  10. Codeforces Round #316 div2

    一场充满血腥hack之战!!! Problem_A: 题意: n个候选人在m个城市进行投票,每个城市选出票数最多的一个候选人为城市候选人,如果票数相同,则取编号小的候选人. 再从这m个城市候选人中选出 ...