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 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)的更多相关文章

  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. 在.net中修改Webbrowser控件的IE版本

    根据32位.64位系统来分别修改对应的注册表路径的键值对,不需要重启程序. /// <summary> /// 修改Webbrowser控件模拟的IE版本 /// </summary ...

  2. Google guava cache源码解析1--构建缓存器(3)

    此文已由作者赵计刚授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. 下面介绍在LocalCache(CacheBuilder, CacheLoader)中调用的一些方法: Ca ...

  3. C/C++掌握技能(三)

    #include<cstdio> ][]={ //平年和闰年的每个月的天数 {,},{,},{,},{,},{,},{,},{,}, {,},{,},{,},{,},{,},{,} }; ...

  4. webpack快速入门——实战技巧:watch的正确使用方法,webpack自动打包

    随着项目大了,后端与前端联调,我们不需要每一次都去打包,这样特别麻烦,我们希望的场景是,每次按保存键,webpack自动为我们打包,这个工具就是watch! 因为watch是webpack自带的插件, ...

  5. Unable to preventDefault inside passive event listener due to target being treated as passive?

    使用滚动时候,新版google浏览器,会弹出如下的警告. 解决方法,可以加上* { touch-action: none; } 这句样式去掉. 其原因:https://developers.googl ...

  6. vue项目axios请求接口,后端代理请求接口404,问题出现在哪?

    在vue项目中,列表数据需要用到qq音乐接口中的数据,但是直接请求不行,有host及referer限制,需要采用后端代理的方式.借助axios及node的express,在dev-server.js中 ...

  7. 记录jquery的ajax

    1.直接干货 ajax很简单jquery有很好的支持,原生js就不写了.总的说常用的有3个方法 $.post $.get $.ajax 具体参数参考教程http://www.runoob.com/jq ...

  8. Spring MVC前后端数据交互总结

    控制器 作为控制器,大体的作用是作为V端的数据接收并且交给M层去处理,然后负责管理V的跳转.SpringMVC的作用不外乎就是如此,主要分为:接收表单或者请求的值,定义过滤器,跳转页面:其实就是ser ...

  9. Shuffle(洗牌)

    Shuffle(洗牌)    图    map        1.Map Task的输出k v,一开始会进入溢写缓冲区中,对数据做处理,比如分区.排序等操作.        2.有几个Map Task ...

  10. idea安装破解永久有效

    首先先在下面地址下载好idea安装包 链接:https://pan.baidu.com/s/1gVl3WAjC_H6jrH2cjK1paw提取码:i2t5 再下载好破解所需的jar包 链接:https ...