Magic Number (zoj3622)
Magic Number (zoj3622)
Time Limit : 4000/2000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 21 Accepted Submission(s) : 7
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
- 开始不理解题意,后来同学给我讲了之后才理解
- 题意;得 xy mod y = 0 ,变形即得 (x*10^(y的位数)+y)mod y = 0,
- 化简得 x*10^(y的位数) mod y = 0 ,题目说对于任意的 x,y都得成立,
- 所以只要 y 是 10^(y的位数) 的因子即可。但是这道题卡时,做的时候老超时,
- 到最后不得不把数据范围内的所有数都打出来,没办法,,,我只能说我能力不够啊,,,还是太水了,,,
- 附代码:
- /*
- #include<stdio.h>
- #include<math.h>
- int main()
- {
- __int64 x,y,t=0,m,k;
- while(scanf("%I64d%I64d",&x,&y)!=EOF)
- {
- int i,j;
- k=0;
- for(i=1;i<pow(2,31);i++)
- {
- t=0;
- m=i;
- while(m)
- {t++;m/=10;}
- int p=1;
- for(j=1;j<=i;j++)
- {
- if((j*(__int64)pow(10,t))%i)
- {p=0;break;}
- }
- if(p)
- {printf("%I64d ",i);}
- }
- printf("\n");
- }
- return 0;
- }
- //我表示时间很漫长,但是你会找到规律的,所以之后的自己写好了,哈哈
- */
- /*
- #include<stdio.h>
- #include<math.h>
- int main()
- {
- __int64 x,y,t=0,m,k;
- while(scanf("%I64d%I64d",&x,&y)!=EOF)
- {
- int i,j;
- k=0;
- for(i=1;i<100;i++)
- {
- t=0;
- m=i;
- while(m)
- {t++;m/=10;}
- int p=1;
- for(j=1;j<=i;j++)
- {
- if((j*(__int64)pow(10,t))%i)
- {p=0;break;}
- }
- if(p)
- {printf("%I64d ",i);}
- }
- __int64 a=100,b=125,c=200,d=250,e=500;
- for(;a<pow(2,31);)//有了上面的规律,这样就可以全部输出来了。。。很快的,哈哈
- {
- printf("%I64d %I64d %I64d %I64d %I64d ",a,b,c,d,e);
- a*=10;
- b*=10;
- c*=10;
- d*=10;
- e*=10;
- }
- printf("\n");
- }
- return 0;
- }
- */
- #include<stdio.h>
- long long int a[]={,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, , , ,, , , , ,, , ,, ,, };
- int main()//我晕,__int64不然过,,,long long 就过了,错误是 Getting complication error information failed! 求解释!
- {
- long long int m,n;
- while(scanf("%lld%lld",&m,&n)!=EOF)
- {
- int i,count=;
- for(i=;i<;i++)
- {
- if(m<=a[i]&&a[i]<=n)
- count++;
- if(a[i]>n)
- break;
- }
- printf("%lld\n",count);
- }
- return ;
- }
这是第一个程序,,,寻找规律。
- 然后第二个程序,就出来了。
- 太心酸了,用int64,PE了N次,改longlong,秒过,求大神解答。
Magic Number (zoj3622)的更多相关文章
- 一个快速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 ...
- [ZOJ 3622] Magic Number
Magic Number Time Limit: 2 Seconds Memory Limit: 32768 KB A positive number y is called magic n ...
- poj magic number
Problem H Time Limit : 4000/2000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Total Sub ...
- ZOJ 3622 Magic Number(数)
题意 假设一个正整数y满足 将随意正整数x放到y的左边得到的数z满足 z%y==0 那么这个数就是个Magic Number 给你一个范围 求这个范围内Magic Number的个数 令 ...
- iOS Exception Code 之 Magic Number
https://en.wikipedia.org/wiki/Hexspeak iOS Exception Code 之 Magic Number 备忘.
- ZOJ 3622 Magic Number 打表找规律
A - Magic Number Time Limit:2000MS Memory Limit:32768KB 64bit IO Format:%lld & %llu Subm ...
- 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 ...
随机推荐
- CentOS 7 - 创建新用户
当进行服务器操作时,我们尽量不要使用root用户进行操作,特别是当我们使用生产环境时. 本文我们将介绍CentOS 7下用户的创建. 创建新用户 adduser 用户名 更改用户密码 passwd 用 ...
- [初识]使用百度AI接口,图灵机器人实现简单语音对话
一.准备 1.百度ai开放平台提供了优质的接口资源https://ai.baidu.com/ (基本免费) 2.在语音识别的接口中, 对中文来说, 讯飞的接口是很好的选择https://www.xf ...
- awk的匹配
关系运算符 含义 用法示例 < 小于 x < y > 大于 x > y
- mysql 存储过程 游标嵌套
基本表temp 包括 name, type, sendCity, getCity 分别对应物流送货司机名, 倒车的第几段, 发货城市, 收货城市 表结构 -- -------------------- ...
- Hive在drop表的时候报错
问题背景: 在安装完Hive之后,初始化mysql是成功的,hive启动也是成功的,也能创建database,在database中也能创建表,也能查看表结构,但是在drop的时候就不行了,在hive ...
- centos7 完整配置openvpn详情教程
1. 什么是OpenVpn OpenVPN 是一个用于创建虚拟专用网络加密通道的软件包,最早是由James Yonan编写的.OpenVPN允许创建的VPN使用公开密钥.电子证书.或者用户名/密码来进 ...
- redmine设置user projects时无法delete的处理方法
对于user,当要在管理员界面处理其projects权限时,发现部分项目只有edit按钮,而部分项目还有一个delete按钮. “delete”,直接点击按钮即可删除对应project权限,表明该pr ...
- PHP的语言构造器
isset和empty看起来像是函数,我们也经常把它当作函数一样使用,但是实际上,它们是语言构造器. php中的语言构造器就相当于C中的预定义宏的意思,它属于php语言内部定义的关键词,不可以被修改, ...
- java8之lambda表达式(2)-方法引用
方法引用使用的地方也是在函数式接口,使用方法引用可以使代码更加简单和便捷 在如下代码中 根据List中字符串长度排序的代码可以写成如下: public static void test1_() { L ...
- [Java初探04]__字符串(String类)相关
前言 接下来将暂时将重心偏移向实际操作,不在将大量时间花费在详细的知识点整理上,将会简略知识总结笔记的记录,加强实际练习的时间,实例练习篇也不再同步进行,我会将部分我觉得重要的源码更新在每节知识点后面 ...