当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3902:The Bad Number

题目描述
John and Brus believe that number N is a very bad number. Thus they try to avoid it every time and everywhere.
Now the guys would like to represent number M as a sum of positive numbers, each of which not exceeding K. But don’t forget about the bad number N! Each summand must not be divisible by N, moreover the number of summands also must not be divisible by N.
Your task is to find the minimal possible number of summands in such representation of M.
For example, if N=3, M=11, K=6 then we can represent M as 5+6, but as far as 6 is divisible by 3 we must have at least 3 summands. But as far as N=3 we can’t have 3 summands and thus the answer is 4. One of the possible ways to represent M is 11=4+4+2+1.
输入解释
The first line contains single integer T – the number of test cases. Each test case consists of a single line containing three integers N, M and K separated by single spaces.
输出解释
For each test case print a single line containing the minimal possible number of summands according to the requirements described above. If it is impossible to do this output “-1” (quotes for clarity) instead.
输入样例
2 
3 11 6 
2 12 47
输出样例
4 
-1
提示
Constraints:
1 ≤ T ≤ 74,
1 ≤ N, M, K ≤ 1000000000 (109).

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3902

最后修改于 2020-10-29T07:15:01+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536