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. 【SPOJ10707】 COT2 Count on a tree II

    SPOJ10707 COT2 Count on a tree II Solution 我会强制在线版本! Solution戳这里 代码实现 #include<stdio.h> #inclu ...

  2. C#知识点提炼期末复习专用

    根据内部消息称:有三类题型:  程序阅读题:2题  简答题:2题 (主要是对概念的考查)  编程题:暂定2-3题 复习要点: .net framework 通用语言开发环境..NET基础类库..NET ...

  3. [Umbraco] 熟悉管理页面

    登录到umbraco管理界面后,发现其后台管理页很简洁 首页看到左侧部分是一个Content和Sections,右侧是管理区域 介绍各个Sections代表的含义: "Content&quo ...

  4. Oracle RAC 环境下的连接管理(转) --- 防止原文连接失效

    崔华老师的文章!!! 这篇文章详细介绍了Oracle RAC环境下的连接管理,分别介绍了什么是 Connect Time Load Balancing.Runtime Connection Load ...

  5. 剑指offer十八之二叉树的镜像

    一.题目 操作给定的二叉树,将其变换为源二叉树的镜像.二叉树的镜像定义:        源二叉树 : 8 / \ 6 10 / \ / \ 5 7 9 11 镜像二叉树: 8 / \ 10 6 / \ ...

  6. IntelliJ IDEA导入多个eclipse项目到同一个workspace下

    IntelliJ IDEA 与eclipse在新建项目上工作区的叫法略有不同,区别见下图. 我们在eclipse都是在新建的workspace目录下新建我们的项目,但是在IDEA中没有workspac ...

  7. PHP:判断客户端是否使用代理服务器及其匿名级别

    要判断客户端是否使用代理服务器,可以从客户端所发送的环境变量信息来判断. 具体来说,就是看HTTP_VIA字段,如果这个字段设置了,说明客户端使用了代理服务器. 匿名级别可以参考下表来判断. 给出一个 ...

  8. Unity学习系列一简介

    一.简介 Unity的目标是为了提升"依赖注入"的思想,去建立更加松耦合的系统.patterns & practices 小组在那个时候实现DI的方式和我们现在认为的DI有 ...

  9. python特殊的数据类型

    lsit 列表是一种有序的数据集合,允许数据类型不一致! 1.定义:l=[1,"s",'2',True,u"您好"] 或者 l=list() 2.访问:l[0] ...

  10. 关于配置 TeamCity 清理历史 artifacts 问题

    使用 CI 一段时间后,artifacts 占用的磁盘会很大,可以配置保留多少天的 artifacts,具体如下: Administration Click the Edit link for any ...