#P16228. [蓝桥杯 2026 省 A] 读取指令

    ID: 18262 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 显示难度普及 上传者: 标签>数学2026蓝桥杯省赛分类讨论

[蓝桥杯 2026 省 A] 读取指令

Problem Description

You are managing an old linear mechanical hard drive, which is divided into NN consecutive sectors (numbered from 11 to NN).

Because of a special allocation rule of the file system, the amount of data stored in sector ii is C×iC \times i bytes (where CC is a constant representing the system cluster size). For example, when C=2C = 2, the data sizes in sectors 11 to 44 are 2,4,6,82, 4, 6, 8 bytes.

Now you need to read exactly WW 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 [l,r][l, r] and read all data in that interval.

Find the minimum number of read commands needed to read exactly WW bytes. Note: each sector can be read at most once. If it is impossible to make the total exactly WW bytes, output −1-1.

Input Format

The first line contains an integer TT, representing the number of test cases.

The next TT lines each contain three integers N,C,WN, C, W, 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 −1-1.

3
4 2 10
4 2 16
4 2 7
1
2
-1

Hint

Constraints and Notes

For 30%30\% of the test cases, 1≤N≤10001 \le N \le 1000, and T=2T = 2.

For all test cases, 1≤N≤1051 \le N \le 10^5, 2≤T≤102 \le T \le 10, 1≤C≤1001 \le C \le 100, 0≤W≤1090 \le W \le 10^9.

Translated by ChatGPT 5