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. laravel save() 返回 null

    原因:引用其他方法时,没有 return save()的操作结果. 在使用save()方法时,发现返回值是:null:

  2. [转载] C 陷阱与缺陷( C traps and Pitfalls )

    本文转自 https://www.xuebuyuan.com/1951579.html 自己找工作过程中复习过的书包括<C traps and Pitfalls>,<编程珠玑> ...

  3. markdown图片设置

    工具:typora 1. 设置图片大小(本节引用自 https://support.typora.io/Resize-Image/) Typora允许使用<img>标签显示图像,也可用于调 ...

  4. 【转】python 关键字

    转自:http://www.cnblogs.com/hongten/p/hongten_python_keywords.html python3.3.2中的关键字如下: The following i ...

  5. 倍增算法总结 ( 含RMQ模板)

    部分题目来自<算法竞赛设计进阶> 问题       给定一个长度为n的数列A,有m个询问,每次给定一个整数T,求出最大的k,满足a[1],a[2]……a[k]的和小于等于T(不会打sigm ...

  6. CORS与JSONP的区别

    CORS与JSONP: a. JSONP只能实现GET请求,而CORS支持所有类型的HTTP请求. b. 使用CORS,开发者可以使用普通的XMLHttpRequest发起请求和获得数据,比起JSON ...

  7. Ubuntu 安装wps-office

    本系列文章由 @YhL_Leo 出品,转载请注明出处. 文章链接: http://blog.csdn.net/yhl_leo/article/details/50288483 本人的ubuntu系统是 ...

  8. Ubuntu 安装 Courier New字体和雅黑consolas字体

    一直觉得Ubuntu下的字体不是很好,但毕竟不影响使用,然后作开发的时候eclipse的字体完全没有windows下的两大适合编成的字体courier new 和consloas .可以使用系统安装字 ...

  9. JAVA集合类型(二)

    JAVA集合类型 (现代的变量集群) watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0J ...

  10. spark源代码action系列-foreach与foreachPartition

    RDD.foreachPartition/foreach的操作 在这个action的操作中: 这两个action主要用于对每一个partition中的iterator时行迭代的处理.通过用户传入的fu ...