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 core使用nginx做反向代理获取客户端ip的问题

    1.正常情况下.net core获取客户端ip是比较简单的 /// <summary> /// 获取客户Ip /// </summary> /// <param name ...

  2. docker容器备份、恢复和迁移volume方案

    volume作为数据的载体,在很多情况下需要对其中的数据进行备份.迁移或是恢复.下面一docker容器的volume为例,说一下备份的技巧. 我们先建立一个容器vol_simple,该容器在/date ...

  3. main函数中如何等待协程运行完毕

    使用channel同步 package main import ( "fmt" ) func printNumber(num int, c chan struct{}) { fmt ...

  4. 6_文件IO

    1. 基本文件读取         readline(),readlines(),write(),writelines()         f.read(size),指定读取文件的字节数,需要注意的是 ...

  5. es 修改拼音分词器源码实现汉字/拼音/简拼混合搜索时同音字不匹配

    [版权声明]:本文章由danvid发布于http://danvid.cnblogs.com/,如需转载或部分使用请注明出处 在业务中经常会用到拼音匹配查询,大家都会用到拼音分词器,但是拼音分词器匹配的 ...

  6. vue教程2-07 微博评论功能

    vue教程2-07 微博评论功能 <!doctype html> <html> <head> <meta charset="utf-8"& ...

  7. (转)Linux 系统监控、诊断工具之 top命令详解

    原文:https://www.linuxidc.com/Linux/2014-12/110563.htm 目录 (1)系统.任务统计信息:(2)进程. cpu 统计信息:(3)最后两行为内存信息:3. ...

  8. 图片训练:使用卷积神经网络(CNN)识别手写数字

    这篇文章中,我们将使用CNN构建一个Tensorflow.js模型来分辨手写的数字.首先,我们通过使之“查看”数以千计的数字图片以及他们对应的标识来训练分辨器.然后我们再通过此模型从未“见到”过的测试 ...

  9. charles撰写工具/compose和Compose New

    撰写工具/compose和Compose New compose 是在原有的请求基础上,修改: compose New 是新出一个弹窗,自己手动一个个的去写: 可以写各种状态:– URL:– Meth ...

  10. 【JAVA】异常笔记

    自定义异常需要注意: 所有异常都必须是 Throwable 的子类. 如果希望写一个检查性异常类,则需要继承 Exception 类. 如果你想写一个运行时异常类,那么需要继承 RuntimeExce ...