A13542 | Buying Shovels
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Polycarp wants to buy exactly $n$ shovels. The shop sells packages with shovels. The store has $k$ types of packages: the package of the $i$ -th type consists of exactly $i$ shovels ( $1 \le i \le k$ ). The store has an infinite number of packages of each type.
Polycarp wants to choose one type of packages and then buy several (one or more) packages of this type. What is the smallest number of packages Polycarp will have to buy to get exactly $n$ shovels?
For example, if $n=8$ and $k=7$ , then Polycarp will buy $2$ packages of $4$ shovels.
Help Polycarp find the minimum number of packages that he needs to buy, given that he:
- will buy exactly $n$ shovels in total;
- the sizes of all packages he will buy are all the same and the number of shovels in each package is an integer from $1$ to $k$ , inclusive.
Polycarp wants to choose one type of packages and then buy several (one or more) packages of this type. What is the smallest number of packages Polycarp will have to buy to get exactly $n$ shovels?
For example, if $n=8$ and $k=7$ , then Polycarp will buy $2$ packages of $4$ shovels.
Help Polycarp find the minimum number of packages that he needs to buy, given that he:
- will buy exactly $n$ shovels in total;
- the sizes of all packages he will buy are all the same and the number of shovels in each package is an integer from $1$ to $k$ , inclusive.
输入格式
The first line contains an integer $t$ ( $1 \le t \le 100$ ) — the number of test cases in the input. Then, $t$ test cases follow, one per line.
Each test case consists of two positive integers $n$ ( $1 \le n \le 10^9$ ) and $k$ ( $1 \le k \le 10^9$ ) — the number of shovels and the number of types of packages.
Each test case consists of two positive integers $n$ ( $1 \le n \le 10^9$ ) and $k$ ( $1 \le k \le 10^9$ ) — the number of shovels and the number of types of packages.
输出格式
Print $t$ answers to the test cases. Each answer is a positive integer — the minimum number of packages.
输入输出样例
输入 #1
5 8 7 8 1 6 10 999999733 999999732 999999733 999999733
输出 #1
2 8 1 999999733 1
The answer to the first test case was explained in the statement.
In the second test case, there is only one way to buy $8$ shovels — $8$ packages of one shovel.
In the third test case, you need to buy a $1$ package of $6$ shovels.
In the second test case, there is only one way to buy $8$ shovels — $8$ packages of one shovel.
In the third test case, you need to buy a $1$ package of $6$ shovels.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted