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 ...
随机推荐
- 使用Python请求http/https时设置失败重试次数
设置请求时的重试规则 import requests from requests.adapters import HTTPAdapter s = requests.Session() a = HTTP ...
- diamond的设计思路
diamond主要包含四个包:diamond-client.diamond-sdk.diamond-server和diamond-util client就非常简单的进行http的调用server拿数据 ...
- ubuntu下wps无法使用搜狗输入法输入中文
sudo vim /usr/bin/et sudo vim /usr/bin/wps sudo vim /usr/bin/wpp 以上三个文件,都加入如下内容后重新打开文档即可 export XMOD ...
- nginx常用的超时配置说明
client_header_timeout 语法 client_header_timeout time默认值 60s上下文 http server说明 指定等待client发送一个请求头的超时时间(例 ...
- java项目打成jar包使用
使用Eclipse打成jar包 1.创建项目hello 2.写java文件 package hell; import java.io.PrintStream; public class Hello { ...
- Linux 学习错误点整理之网络配置
本人是一名实习生,最近在学习Linux,在实操的过程中还是遇到了一些问题,所以想记录下来,供自己以后复习,也希望能给跟我一样的菜鸟的人带来一点点帮助. 我用的是VMware Workstation P ...
- 【sping揭秘】12、SpringAOP的实现机制
SpringAOP的实现机制 设计模式代理模式 参考我之前的代理模式 http://www.cnblogs.com/cutter-point/p/5226642.html 这里写个简单的案例 pack ...
- 发布上线前,先小秀一把俺的64位浏览器,速度那觉对是杠杠滴,上youtube,上google不费劲
发布上线前,先小秀一把俺的64位浏览器,速度那觉对是杠杠滴,上youtube,上google不费劲
- 剑指offer七之斐波那契数列
一.题目 大家都知道斐波那契数列,现在要求输入一个整数n,请你输出斐波那契数列的第n项.n<=39. 二.思路 序号: 0 1 2 3 4 5 ...
- eclipse下搭建shell脚本编辑器--安装开发shell的eclipse插件shelled
具体请看: 亲测有效: http://www.cnblogs.com/shellshell/p/6122811.html
太心酸了,用int64,PE了N次,改longlong,秒过,求大神解答。