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 ...
随机推荐
- Asp.Net Mvc异步上传文件的方式
今天试了下mvc自带的ajax,发现上传文件时后端action接收不到文件, Request.Files和HttpPostedFileBase都接收不到.....后来搜索了下才知道mvc自带的Ajax ...
- [R]关于R语言的绘图函数
1. 首先就是plot(x,y,...) 参数: x: 所绘图形横坐标构成的对象 y: 所绘图形纵坐标构成的对象 type: 指定所绘图形类型 pch: 指定绘制点时使用的符号 cex: 指定符号的大 ...
- Flask中的before_request和after_request
1.@app.before_request 在请求(request)之前做出响应 @app.before_request 也是一个装饰器,他所装饰的函数,都会在请求进入视图函数之前执行 2.@app. ...
- linux 时间相关
CentOS7 正确修改时区方法 ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
- 虚拟机安装centos7
主要参考这个文档(我已经把网页保存到本地了): http://www.bkjia.com/Linuxjc/867013.html 主要注意: 1.虚拟机网络我选择的桥接模式,在CentOS安装时打开这 ...
- Swift 里 Set(四)Testing for Membership
即contains操作 /// - Parameter member: An element to look for in the set. /// - Returns: `true` if `mem ...
- Java - 集成开发环境Eclipse的使用方法和技巧
00 - Eclipse教程 Eclipse 教程 01 - Eclipse设置编译和运行的环境 建议编译和运行的版本保持一致,否则请特别注意: 低编译,高运行 ---> 可行. 高编译,低运行 ...
- Others - On Duty
On Duty This is xxx and will be duty engineer in the next week. Thanks. Here is a kindly reminder. T ...
- editplus来编写html
本来写这篇文章,我可以有很多废话,但是很多都过去了,言而总之下:我暂且给这个方法起个名字,叫做“为之法”,因为有了这篇文章,很多人的想法会豁然开朗,那样有了个名字交流传阅起来就方便多了. 本方法依托于 ...
- oralce11g RAC 启动后 CRS-0184: Cannot communicate with the CRS daemon.
很奇怪的一个问题! ORACLE数据库服务器,系统启动之后,查看集群状态,发现CRS实例不可用,然后网上查找资料: 隔了几分钟之后,再次查询相关集群服务状态,发现正常了!!! 暂时得出的结论:操作系统 ...