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

Discussions

About Discussions

The discussion section is only for posting: Editorials, General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues. Submitting multiple issues may cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.