CF2072A.New World, New Me, New Array

传统题 时间 2000 ms 内存 256 MiB 3 尝试 1 已通过 1 标签

New World, New Me, New Array

Natsume Akito has just woken up in a new world and immediately received his first quest! The system provided him with an array aa of nn zeros, an integer kk, and an integer pp.

In one operation, Akito chooses two integers ii and xx such that 1in1 \le i \le n and pxp-p \le x \le p, and performs the assignment ai=xa_i = x.

Akito is still not fully accustomed to controlling his new body, so help him calculate the minimum number of operations required to make the sum of all elements in the array equal to kk, or tell him that it is impossible.

Input

The first line of input contains one integer tt (1t10001 \le t \le 1000) — the number of test cases.

The only line of each test case contains three integers nn, kk, pp (1n501 \le n \le 50, 2500k2500-2500 \le k \le 2500, 1p501 \le p \le 50) — the length of the array, the required sum, and the boundary of the segment from which numbers can be replaced.

Output

For each test case, output the minimum number of operations to achieve the final sum kk in the array, or 1-1 if it is impossible to achieve the sum kk.

Note

In the fifth example, the sum of the array is initially zero, so no operations are needed.

In the sixth example, the maximum sum in the array that we can achieve is 99 (by assigning the number 99 to the single element), so the sum 1010 cannot be obtained by any operations.

In the seventh example, only one operation a3=7a_3 = -7 is needed.

Samples

8
21 100 10
9 -420 42
5 -7 2
13 37 7
10 0 49
1 10 9
7 -7 7
20 31 1
10
-1
4
6
0
-1
1
-1

在线编程 IDE

建议全屏模式获得最佳体验