poj magic number
Problem H
Time Limit : 4000/2000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 24 Accepted Submission(s) : 8
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
怎样打表
这些数都是有规律的从100开始后面都只是加了个0而已,所以可以很快找出来。pow(2,31)=2147483648;
#include<stdio.h>
#include<math.h>
int main()
{
long long int a[]={,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, , , ,, , , , ,, , ,, ,, };
long long m,n,i,t;//不能用I64,wa了用long long,而且vc编译器是非法的。
while(~scanf("%lld%lld",&m,&n))
{
t=;
for(i=;i<;i++)
{
if(a[i]>=m&&a[i]<=n)
t++;
if(a[i]>n)
break;
}
printf("%lld\n",t);
}
return ;
}
把数组的那些数是怎样弄出来的代码:
#include<stdio.h>
#include<math.h>
int main()
{
__int64 x,y,t=,m,k;
while(scanf("%I64d%I64d",&x,&y)!=EOF)
{
int i,j;
k=;
for(i=;i<pow(,);i++)
{
t=;
m=i;
while(m)
{
t++;m/=;
}
int p=;
for(j=;j<=i;j++)
{
if((j*(__int64)pow(,t))%i)
{
p=;
break;
}
}
if(p)
{
printf("%I64d ",i);
}
}
printf("\n");
}
return ;
}
poj magic number的更多相关文章
- 一个快速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 ...
- 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 备忘.
- Magic Number (zoj3622)
Magic Number (zoj3622) Time Limit : 4000/2000ms (Java/Other) Memory Limit : 65536/32768K (Java/Oth ...
- 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 ...
随机推荐
- 搭建java开发环境
windows 去Oracle官网下载exe文件,双击安装. 修改系统环境变量(我的电脑 -> 属性 -> 高级 -> 环境变量). JAVA_HOME: D:\Java\jdk1. ...
- 实例:图形绘制[OpenCV 笔记15]
DrawShapes.cxx # include "DrawShapes_utils.h" #define WINDOW_NAME1 "Painting 1" ...
- Qt 操作Excel
Qt对Excel的数据读/写操作没有现存的类,需要使用QAxObject,下面是从网上下载下来的一个封装好的类,感觉还可以,一般情况下够用,拿来给大家分享. 头文件: #ifndef EXCELENG ...
- Essential C++ 学习笔记01--基本语法
<Essential C++>1.1-1.4节笔记 1. main 函数 main 函数是代码的入口,若无 main 函数,编译不通过. main 函数通常声明为 int, return ...
- ConcurrentHashMap中的2的n次方幂上舍入方法
最近看JDK中的concurrentHashMap类的源码,其中有那么一个函数: /** * Returns a power of two table size for the given desir ...
- android程序的安装与卸载
Android android在安装应用程序与卸载应用程序时都会发送广播,安装应用程序成功时会发送android.intent.action.PACKAGE_ADDED广播,可以通过intent.ge ...
- [C#]『Task』任务并行库使用小计
1.简单创建使用 using System; using System.Diagnostics; using System.Threading; using System.Threading.Task ...
- markdown与textile之间互相转换
markdown与textile之间互相转换 redmine中默认使用的是textile那么从别的地方复制过来的markdown格式的内容需要进行转换 找到一款工具叫做pandoc http://jo ...
- vagrant 设置除默认工项目之外的synced_folder一个坑
vagrant和host共享的目录,模式是以host主机目录为主,vagrant目录为从,所以记住当你新建同步目录的时候一定要先把vagratn目录文件备份一下,不然会被host目录覆盖
- 基于ActiveMQ的点对点收发消息
ActiveMQ是apache的一个开源消息引擎.可以作为即通引擎或者消息中间件引擎. 准备 下载ActiveMQ http://activemq.apache.org/download.html 进 ...