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. 常用Yum镜像源

    163网易的yum源 wget http://mirrors.163.com/.help/CentOS6-Base-163.repo sohu的yum源 wget http://mirrors.soh ...

  2. Django设置联合唯一约束 -- migrate时报错处理

    异常信息: a unique database constraint for 2 or more fields together 场景描述: 对于ORM中多对多关系的中间表,如果该关系表是手动创建的, ...

  3. [转]网页实时聊天之js和jQuery实现ajax长轮询 PHP

    网页实时聊天之js和jQuery实现ajax长轮询 众所周知,HTTP协议是无状态的,所以一次的请求都是一个单独的事件,和前后都没有联系.所以我们在解决网页实时聊天时就遇到一个问题,如何保证与服务器的 ...

  4. 【源码分析】HashMap源码再读-基于Java8

    最近工作不是太忙,准备再读读一些源码,想来想去,还是先从JDK的源码读起吧,毕竟很久不去读了,很多东西都生疏了.当然,还是先从炙手可热的HashMap,每次读都会有一些收获.当然,JDK8对HashM ...

  5. 目标检测技术演进:R-CNN、Fast R-CNN、Faster R-CNN

    看到一篇循序渐进讲R-CNN.Fast R-CNN.Faster R-CNN演进的博文,写得非常好,摘入于此,方便查找和阅读. object detection,就是在给定的图片中精确找到物体所在位置 ...

  6. Netty——高级内置解码器、编码器、ByteBuf

    netty通讯需要对数据进行编码,解码,于是我们需要用到netty的编码器.解码器   netty 提供的解码器 DelimiterBasedFrameDecoder 解决TCP的粘包解码器 Stri ...

  7. Linux添加防火墙、iptables的安装和配置(亲测)

    iptables基础 规则(rules)其实就是网络管理员预定义的条件,规则一般的定义为“如果数据包头符合这样的条件,就这样处理这个数据包”.规则存储在内核空间的信息 包过滤表中,这些规则分别指定了源 ...

  8. Solidity数组

    一.固定长度的数组(Arrays) 1.固定长度类型数组的声明 pragma solidity ^0.4.4; contract C { // 数组的长度为5,数组里面的存储的值的类型为uint类型 ...

  9. Spring-IOC注解

    注解主要的目的就是实现零XML配置.一:自动扫描装配Bean. spring为我们引入了组件自动扫描机制,它可以在类路径底下寻找标注了@Component.@Service.@Controller.@ ...

  10. Java 使用gson 解析 Json

    json数据 { "resultcode": "200", "reason": "successed!", " ...