Codeforces Round 921 (Div. 2)
B
A Balanced Problemset?
Codeforces
1200
原题
← AC →
翻译中…

Jay managed to create a problem of difficulty $x$ and decided to make it the second problem for Codeforces Round #921.

翻译中…

But Yash fears that this problem will make the contest highly unbalanced, and the coordinator will reject it. So, he decided to break it up into a problemset of $n$ sub-problems such that the difficulties of all the sub-problems are a positive integer and their sum is equal to $x$.

翻译中…

The coordinator, Aleksey, defines the balance of a problemset as the GCD of the difficulties of all sub-problems in the problemset.

翻译中…

Find the maximum balance that Yash can achieve if he chooses the difficulties of the sub-problems optimally.

翻译中…

Input

翻译中…

The first line of input contains a single integer $t$ ($1\leq t\leq 10^3$) denoting the number of test cases.

翻译中…

Each test case contains a single line of input containing two integers $x$ ($1\leq x\leq 10^8$) and $n$ ($1\leq n\leq x$).

翻译中…

Output

翻译中…

For each test case, print a single line containing a single integer denoting the maximum balance of the problemset Yash can achieve.

翻译中…

Note

翻译中…

For the first test case, one possible way is to break up the problem of difficulty $10$ into a problemset having three problems of difficulties $4$, $2$ and $4$ respectively, giving a balance equal to $2$.

翻译中…

For the second test case, there is only one way to break up the problem of difficulty $5$ into a problemset of $5$ problems with each problem having a difficulty $1$ giving a balance equal to $1$.

翻译中…

样例

Input #1
3
10 3
5 5
420 69
Output #1
2
1
6
InputCopy OutputCopy
题目信息
题号
1925B
时间限制
1.5 s
内存限制
256 MB
标签
暴力
贪心
数学
数论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。