bzoj#P2488. Pku3902 The Bad Number

Pku3902 The Bad Number

题目描述

John and Brus believe that number NN is a very bad number.Thus they try to avoid it every time and everywhere.
Now the guys would like to represent number MM as a sum of positive numbers,each of which not exceeding KK.But don’t forget about the bad number NN!Each summand must not be divisible by NN,moreover the number of summands also must not be divisible by NN
Your task is to find the minimal possible number of summands in such representation of MM
For example,if N=3,M=11,K=6N=3,M=11,K=6 then we can represent MM as 5+65+6,but as far as 66 is divisible by 33 we must have at least 33 summands.But as far as N=3N=3 we can’t have 33 summands and thus the answer is 44.One of the possible ways to represent MM is 11=4+4+2+111=4+4+2+1

给你三个整数 N,M,KN,M,K,求一个最小的 PP,使得 MM 能够被分成 PP 个正整数的和。
并且这些整数要满足:(一)不能是 NN 的倍数,(二)大小不能超过 KK,并且 PP也不能是 NN 的倍数。

输入格式

The first line contains single integer TT – the number of test cases.Each test case consists of a single line containing three integers N,MN,M and KK 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

数据规模与约定

100%100\% 的数据满足:1T74,N,M,K1091 \le T \le 74,N,M,K \le 10^9