QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 512 MB Total points: 100

#8758. Menji 和 gcd

統計

题目描述

Menji 喜欢最大公约数,特别是最大公约数大的正整数对。

令 $\gcd(x,y)$ 表示 $x,y$ 的最大公约数,多次给定 $L,R$,保证 $L < R$,求 $\max\limits_{L\leq x < y\leq R}\gcd(x,y)$。

输入格式

从标准输入读入数据。

第一行一个正整数 $T(1\leq T\leq 10)$,表示数据组数。

之后 $T$ 行,每行两个正整数 $L,R(1\leq L < R\leq 10^{12})$,表示一组询问。

输出格式

输出到标准输出。

对于每个询问 $L,R$,输出一行一个正整数 $\max\limits_{L\leq x < y\leq R}\gcd(x,y)$。

样例

输入

10
1 2
2 4
6 10
11 21
147 154
1470 1540
2890 3028
998244353 1000000007
34827364537 41029384775
147147147147 154154154154

输出

1
2
3
7
7
70
126
1754385
5861340682
7007007007
About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.