Magic Number (zoj3622)

Time Limit : 4000/2000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 21   Accepted Submission(s) : 7
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
  3.  
  4. 开始不理解题意,后来同学给我讲了之后才理解
  1. 题意;得 xy mod y = 0 ,变形即得 x*10^(y的位数)+ymod y = 0
  2. 化简得 x*10^(y的位数) mod y = 0 ,题目说对于任意的 xy都得成立,
  3. 所以只要 y 10^(y的位数) 的因子即可。但是这道题卡时,做的时候老超时,
  4. 到最后不得不把数据范围内的所有数都打出来,没办法,,,我只能说我能力不够啊,,,还是太水了,,,
  5. 附代码:
  1. /*
  2. #include<stdio.h>
  3. #include<math.h>
  4. int main()
  5. {
  6. __int64 x,y,t=0,m,k;
  7. while(scanf("%I64d%I64d",&x,&y)!=EOF)
  8. {
  9. int i,j;
  10. k=0;
  11. for(i=1;i<pow(2,31);i++)
  12. {
  13. t=0;
  14. m=i;
  15. while(m)
  16. {t++;m/=10;}
  17. int p=1;
  18. for(j=1;j<=i;j++)
  19. {
  20. if((j*(__int64)pow(10,t))%i)
  21. {p=0;break;}
  22. }
  23. if(p)
  24. {printf("%I64d ",i);}
  25. }
  26. printf("\n");
  27. }
  28. return 0;
  29. }
  30.  
  31. //我表示时间很漫长,但是你会找到规律的,所以之后的自己写好了,哈哈
  32. */
  33.  
  34. /*
  35. #include<stdio.h>
  36. #include<math.h>
  37. int main()
  38. {
  39. __int64 x,y,t=0,m,k;
  40. while(scanf("%I64d%I64d",&x,&y)!=EOF)
  41. {
  42. int i,j;
  43. k=0;
  44. for(i=1;i<100;i++)
  45. {
  46. t=0;
  47. m=i;
  48. while(m)
  49. {t++;m/=10;}
  50. int p=1;
  51. for(j=1;j<=i;j++)
  52. {
  53. if((j*(__int64)pow(10,t))%i)
  54. {p=0;break;}
  55. }
  56. if(p)
  57. {printf("%I64d ",i);}
  58. }
  59. __int64 a=100,b=125,c=200,d=250,e=500;
  60. for(;a<pow(2,31);)//有了上面的规律,这样就可以全部输出来了。。。很快的,哈哈
  61. {
  62. printf("%I64d %I64d %I64d %I64d %I64d ",a,b,c,d,e);
  63. a*=10;
  64. b*=10;
  65. c*=10;
  66. d*=10;
  67. e*=10;
  68. }
  69. printf("\n");
  70. }
  71. return 0;
  72. }
  73.  
  74. */
  75.  
  76. #include<stdio.h>
  77.  
  78. long long int a[]={,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, , , ,, , , , ,, , ,, ,, };
  79.  
  80. int main()//我晕,__int64不然过,,,long long 就过了,错误是 Getting complication error information failed! 求解释!
  81. {
  82. long long int m,n;
  83. while(scanf("%lld%lld",&m,&n)!=EOF)
  84. {
  85. int i,count=;
  86. for(i=;i<;i++)
  87. {
  88. if(m<=a[i]&&a[i]<=n)
  89. count++;
  90. if(a[i]>n)
  91. break;
  92. }
  93. printf("%lld\n",count);
  94. }
  95. return ;
  96. }
  1.  

这是第一个程序,,,寻找规律。

  1. 然后第二个程序,就出来了。
  2. 太心酸了,用int64PEN次,改longlong,秒过,求大神解答。
  1.  

Magic Number (zoj3622)的更多相关文章

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

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

  6. ZOJ 3622 Magic Number(数)

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

  7. iOS Exception Code 之 Magic Number

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

  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. Asp.Net Mvc异步上传文件的方式

    今天试了下mvc自带的ajax,发现上传文件时后端action接收不到文件, Request.Files和HttpPostedFileBase都接收不到.....后来搜索了下才知道mvc自带的Ajax ...

  2. [R]关于R语言的绘图函数

    1. 首先就是plot(x,y,...) 参数: x: 所绘图形横坐标构成的对象 y: 所绘图形纵坐标构成的对象 type: 指定所绘图形类型 pch: 指定绘制点时使用的符号 cex: 指定符号的大 ...

  3. Flask中的before_request和after_request

    1.@app.before_request 在请求(request)之前做出响应 @app.before_request 也是一个装饰器,他所装饰的函数,都会在请求进入视图函数之前执行 2.@app. ...

  4. linux 时间相关

    CentOS7 正确修改时区方法 ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

  5. 虚拟机安装centos7

    主要参考这个文档(我已经把网页保存到本地了): http://www.bkjia.com/Linuxjc/867013.html 主要注意: 1.虚拟机网络我选择的桥接模式,在CentOS安装时打开这 ...

  6. Swift 里 Set(四)Testing for Membership

    即contains操作 /// - Parameter member: An element to look for in the set. /// - Returns: `true` if `mem ...

  7. Java - 集成开发环境Eclipse的使用方法和技巧

    00 - Eclipse教程 Eclipse 教程 01 - Eclipse设置编译和运行的环境 建议编译和运行的版本保持一致,否则请特别注意: 低编译,高运行 ---> 可行. 高编译,低运行 ...

  8. Others - On Duty

    On Duty This is xxx and will be duty engineer in the next week. Thanks. Here is a kindly reminder. T ...

  9. editplus来编写html

    本来写这篇文章,我可以有很多废话,但是很多都过去了,言而总之下:我暂且给这个方法起个名字,叫做“为之法”,因为有了这篇文章,很多人的想法会豁然开朗,那样有了个名字交流传阅起来就方便多了. 本方法依托于 ...

  10. oralce11g RAC 启动后 CRS-0184: Cannot communicate with the CRS daemon.

    很奇怪的一个问题! ORACLE数据库服务器,系统启动之后,查看集群状态,发现CRS实例不可用,然后网上查找资料: 隔了几分钟之后,再次查询相关集群服务状态,发现正常了!!! 暂时得出的结论:操作系统 ...