RGCDQ

Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1652    Accepted Submission(s): 696

Problem Description
Mr. Hdu is interested in Greatest Common Divisor (GCD). He wants to find more and more interesting things about GCD. Today He comes up with Range Greatest Common Divisor Query (RGCDQ). What’s RGCDQ? Please let me explain it to you gradually. For a positive integer x, F(x) indicates the number of kind of prime factor of x. For example F(2)=1. F(10)=2, because 10=2*5. F(12)=2, because 12=2*2*3, there are two kinds of prime factor. For each query, we will get an interval [L, R], Hdu wants to know maxGCD(F(i),F(j)) (L≤i<j≤R)
 
Input
There are multiple queries. In the first line of the input file there is an integer T indicates the number of queries.
In the next T lines, each line contains L, R which is mentioned above.

All input items are integers.
1<= T <= 1000000
2<=L < R<=1000000

 
Output
For each query,output the answer in a single line. 
See the sample for more details.
 
Sample Input
2
2 3
3 5
 
Sample Output
1
1
 
Author
ZSTU
 
Source
 
解题:打表。。。学习了Crazyacking的写法
 
 #include <bits/stdc++.h>
using namespace std;
const int maxn = ; int sum[maxn][],kinds[maxn];
bool np[maxn];
void init() {
for(int i = ; i < maxn; ++i)
if(!np[i]) {
for(int j = i; j < maxn; j += i) {
np[j] = true;
++kinds[j];
}
}
for(int i = ; i < maxn; ++i)
for(int j = ; j > ; --j)
sum[i][j] = kinds[i] == j;
for(int i = ; i < maxn; ++i)
for(int j = ; j > ; --j)
sum[i][j] += sum[i-][j];
//记录1到上界含有j个不同素因子的数的个数
}
int main() {
int kase,a,b;
init();
scanf("%d",&kase);
while(kase--) {
scanf("%d%d",&a,&b);
for(int i = ; i > ; --i) {
if(sum[b][i] - sum[a-][i] > ) {
printf("%d\n",i);
break;
}
}
}
return ;
}

2015 Multi-University Training Contest 3 hdu 5317 RGCDQ的更多相关文章

  1. 2015 Multi-University Training Contest 8 hdu 5390 tree

    tree Time Limit: 8000ms Memory Limit: 262144KB This problem will be judged on HDU. Original ID: 5390 ...

  2. 2015 Multi-University Training Contest 8 hdu 5383 Yu-Gi-Oh!

    Yu-Gi-Oh! Time Limit: 2000ms Memory Limit: 65536KB This problem will be judged on HDU. Original ID:  ...

  3. 2015 Multi-University Training Contest 8 hdu 5385 The path

    The path Time Limit: 2000ms Memory Limit: 65536KB This problem will be judged on HDU. Original ID: 5 ...

  4. 2015 Multi-University Training Contest 3 hdu 5324 Boring Class

    Boring Class Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Tota ...

  5. 2015 Multi-University Training Contest 10 hdu 5406 CRB and Apple

    CRB and Apple Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)To ...

  6. 2015 Multi-University Training Contest 10 hdu 5412 CRB and Queries

    CRB and Queries Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Other ...

  7. 2015 Multi-University Training Contest 6 hdu 5362 Just A String

    Just A String Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)T ...

  8. 2015 Multi-University Training Contest 6 hdu 5357 Easy Sequence

    Easy Sequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)T ...

  9. 2015 Multi-University Training Contest 7 hdu 5378 Leader in Tree Land

    Leader in Tree Land Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Othe ...

随机推荐

  1. 使用tf.ConfigProto()配置Session运行参数和GPU设备指定

    参考链接:https://blog.csdn.net/dcrmg/article/details/79091941 tf.ConfigProto()函数用在创建session的时候,用来对sessio ...

  2. 通过CSS样式隐藏百度版权标志

    在JSP中添加: //隐藏所有.anchorBL{ display:none; } //隐藏下方的保留百度地图图片 .BMap_cpyCtrl{ display:none; }   注:维护他人版权, ...

  3. java string遇到的一个奇葩bug

    String abc = "1"; HashMap<String, String> hMap = new HashMap<String, String>() ...

  4. 关于VMNet1、VMNet8、

    关于vmnet1~~~~~vmnet8 2008年04月11日 星期五 23:18 先说vmnet0,实际上就是一个虚拟的网桥,这个网桥有很若干个端口,一个端口用于连接你的Host,一个端口用于连接你 ...

  5. HDU 2841

    明显,当(X,Y)=1时,是可以看见的. 这题,记得POJ 上也有类似的一题... 不过比较奇怪的是,我以为会超时,因为范围达到了100000,但竟然直接枚举没超时.... #include < ...

  6. 2015级C++第2周实践项目

    [项目1 - 宣告"主权"] 你已经是CSDN博客主了,用IT人特有的方式,编一段程序.在屏幕上输出你想说的话.按要求公布博文,作为我们的开山之作. [项目2 - 胖子不想说体重] ...

  7. jQuery中focusin()和focus()、find()和children()的差别

    jQuery中focus()和focusin().focus()和children()的差别 focus()和focusin() focus()和focusin()的差别在于focusin()支持事件 ...

  8. Hibernate关系映射中的注解

    一.@Entity 写在映射表的类上面,表示这是映射来的实体 二.@Id @Column(name = "fid", nullable = false) @Basic @Colum ...

  9. LeetCode——Pascal&#39;s Triangle II

    Given an index k, return the kth row of the Pascal's triangle. For example, given k = 3, Return [1,3 ...

  10. javascript 获取指定范围随机数

    <script type="text/javascript"> function GetRandomNum(Min,Max){ var Range = Max - Mi ...