A11352 | A Balanced Problemset?
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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](https://en.wikipedia.org/wiki/Greatest_common_divisor) 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.
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](https://en.wikipedia.org/wiki/Greatest_common_divisor) 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.
输入格式
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$ ).
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$ ).
输出格式
For each test case, print a single line containing a single integer denoting the maximum balance of the problemset Yash can achieve.
输入输出样例
输入 #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 $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$ .
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$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted