CF2194A.Lawn Mower
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
The exit from the summer cottage is fenced with a fence consisting of n boards, each 1 meter wide. To the left and right of the exit are the fences of other plots. Some of the boards of the fence want to be removed for the construction of a bathhouse (possibly all or none), while there is an automatic lawn mower on the plot that is w meters wide and must not leave the plot through a hole in the fence.
The lawn mower will be able to exit the plot if there are at least w consecutive removed boards among the numbers of the removed boards. Determine the maximum number of boards that can be removed from the fence.
夏季小屋的出口处围有一道由 n 块木板组成的栅栏,每块木板宽 1 米。出口左右两侧分别是其他地块的栅栏。这些栅栏木板中,部分(可能全部,也可能不移除任何一块)将被拆除用于建造浴室。然而,地块上有一台自动割草机,其宽度为 w 米,它不得通过栅栏上的缺口离开该地块。
当被拆除的木板中存在至少 w 块连续编号的木板时,割草机即可离开地块。试求:最多可拆除多少块栅栏木板?
输入格式
Each test contains multiple test cases. The first line contains the number of test cases t (1≤t≤104). The description of the test cases follows.
The only line of each test case contains two integers n and w (1≤n≤109, 1≤w≤109) — the number of boards in the fence and the width of the lawnmower in meters, respectively.
每个测试包含多个测试用例。第一行包含测试用例的数量 t(1≤t≤104)。随后是各测试用例的描述。
每个测试用例仅有一行,包含两个整数 n 和 w(1≤n≤109,1≤w≤109),分别表示围栏中的木板数量和割草机的宽度(单位:米)。
输出格式
For each test case, output a single number — the maximum number of boards that can be removed from the fence.
对于每个测试用例,输出一个整数——即可以从围栏中移除的木板的最大数量。
输入输出样例
输入#1
5 9 3 13 4 15 14 20 1 1000 42
输出#1
6 10 14 0 977
说明/提示
In the first test case, the fence consists of 9 boards.

You can remove 6 boards and leave only the boards numbered 2, 5, and 8. Then the lawn mower will not be able to leave the boundaries of the territory.

In the second test case, you can remove 10 boards, a possible arrangement is shown below.

在第一个测试用例中,围栏由 9 块木板组成。

你可以移除 6 块木板,仅保留编号为 2、5 和 8 的木板。此时割草机将无法离开该区域的边界。

在第二个测试用例中,你可以移除 10 块木板,一种可能的排列如下所示。

输入解题思路,AI测评打分。不知道怎么写?