CF1925B.A Balanced Problemset?

普及-

通过率:0%

时间限制:1.50s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Jay managed to create a problem of difficulty xx 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 nn sub-problems such that the difficulties of all the sub-problems are a positive integer and their sum is equal to xx.

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.

杰伊成功设计了一道难度为 xx 的题目,并决定将其作为 Codeforces Round #921 的第二题。

但亚什担心这道题会使比赛严重失衡,导致协调员拒绝它。因此,他决定将该题拆分为一个包含 nn 道子题的问题集,使得所有子题的难度均为正整数,且它们的难度之和等于 xx。

协调员阿列克谢将问题集的平衡度定义为该问题集中所有子题难度的最大公约数(GCD)(参见 GCD)。

若亚什能最优地选择各子题的难度,请你求出他所能达到的最大平衡度。

输入格式

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

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

输入的第一行包含一个整数 tt(1≤t≤1031\leq t\leq 10^3),表示测试用例的数量。

每个测试用例包含一行输入,其中包含两个整数 xx(1≤x≤1081\leq x\leq 10^8)和 nn(1≤n≤x1\leq n\leq x)。

输出格式

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

对于每个测试用例,输出一行,包含一个整数,表示 Yash 能够达到的最大平衡值。

输入输出样例

  • 输入#1

    3
    10 3
    5 5
    420 69

    输出#1

    2
    1
    6

说明/提示

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

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

对于第一个测试用例,一种可行的方式是将难度为 1010 的题目拆分为一个包含三道题的问题集,其难度分别为 44、22 和 44,从而得到平衡值为 22。

对于第二个测试用例,唯一的方式是将难度为 55 的题目拆分为一个包含 55 道题的问题集,每道题的难度均为 11,从而得到平衡值为 11。

输入解题思路,AI测评打分。不知道怎么写?

首页