CF1360D.Buying Shovels
普及-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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≤i≤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 想要恰好购买 n 把铲子。商店出售成包的铲子,共有 k 种不同规格的包装:第 i 种包装恰好包含 i 把铲子(1≤i≤k)。每种规格的包装数量无限。
Polycarp 打算只选择一种规格的包装,然后购买若干个(至少一个)该规格的包装。他最少需要购买多少个包装,才能恰好获得 n 把铲子?
例如,若 n=8 且 k=7,则 Polycarp 将购买 2 个每包 4 把铲子的包装。
请帮助 Polycarp 找出他需要购买的最少包装数量,要求满足:
- 总共恰好购买 n 把铲子;
- 所有购买的包装规格完全相同,且每个包装所含铲子数量为 1 到 k(含端点)之间的整数。
输入格式
The first line contains an integer t (1≤t≤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≤n≤109) and k (1≤k≤109) — the number of shovels and the number of types of packages.
第一行包含一个整数 t(1≤t≤100),表示输入中测试用例的数量。随后是 t 个测试用例,每个测试用例占一行。
每个测试用例包含两个正整数 n(1≤n≤109)和 k(1≤k≤109),分别表示铲子的数量和包装类型的数量。
输出格式
Print t answers to the test cases. Each answer is a positive integer — the minimum number of packages.
输出 t 个测试用例的答案。每个答案均为一个正整数——即最少的包裹数量。
输入输出样例
输入#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.
第一个测试用例的答案已在题目描述中说明。
在第二个测试用例中,购买 8 把铲子只有一种方式——购买 8 个每包 1 把铲子的包装。
在第三个测试用例中,你需要购买 1 个每包 6 把铲子的包装。
输入解题思路,AI测评打分。不知道怎么写?