#P16228. [蓝桥杯 2026 省 A] 读取指令
[蓝桥杯 2026 省 A] 读取指令
Problem Description
You are managing an old linear mechanical hard drive, which is divided into consecutive sectors (numbered from to ).
Because of a special allocation rule of the file system, the amount of data stored in sector is bytes (where is a constant representing the system cluster size). For example, when , the data sizes in sectors to are bytes.
Now you need to read exactly bytes of data from this hard drive for recovery. To minimize head-seeking cost, you are only allowed to send “read commands” to the drive. Each command can specify a continuous sector interval and read all data in that interval.
Find the minimum number of read commands needed to read exactly bytes. Note: each sector can be read at most once. If it is impossible to make the total exactly bytes, output .
Input Format
The first line contains an integer , representing the number of test cases.
The next lines each contain three integers , separated by spaces.
Output Format
For each test case, output one integer per line, representing the minimum number of read commands. If it is impossible, output .
3
4 2 10
4 2 16
4 2 7
1
2
-1
Hint
Constraints and Notes
For of the test cases, , and .
For all test cases, , , , .
Translated by ChatGPT 5