STEVE - Voracious Steve

题意翻译

## Problem Steve和他的一个朋友在玩游戏,游戏开始前,盒子里有 n个甜甜圈,两个人轮流从盒子里抓甜甜圈,每次至少抓 1个,最多抓m个。 最后一次将当盒子的甜甜圈抓完的人是这一轮游戏胜利者,他可以将所有抓到的甜甜圈吃完,另外一个人是这轮的失败者,他抓到的所有甜甜圈要重新放到盒子里。 下一轮游戏由上一轮的失败者开始抓,游戏继续。直到若干轮后,所有的甜甜圈被吃完,游戏结束。 游戏的目标是吃到尽量多的甜甜圈。游戏最开始,由Steve先抓,两个人均采用最优策略,请问Steve最多可以吃到多少甜甜圈。 ## Input Data 第一行输入t,表示有t组测试数据 第2~t行,两个整数n和m(1≤m≤n≤100) ## Output Data 一行,一个整数,表示Steve最多可以吃到多少个甜甜 圈。 ## Input Sample 1 1 5 2 ## Output Sample 1 3

题目描述

Steve and Digit bought a box containing a number of donuts. In order to divide them between themselves they play a special game that they created. The players alternately take a certain, positive number of donuts from the box, but no more than some fixed integer. Each player's donuts are gathered on the player's side. The player that empties the box eats his donuts while the other one puts his donuts back into the box and the game continues with the "loser" player starting. The game goes on until all the donuts are eaten. The goal of the game is to eat the most donuts. How many donuts can Steve, who starts the game, count on, assuming the best strategy for both players? ### Task Write a program that: - reads the parameters of the game from the standard input, - computes the number of donuts Steve can count on, - writes the result to the standard output.

输入输出格式

输入格式


The input begins with the integer t, the number of test cases. Then t test cases follow. For each test case the first and only line of the input contains exactly two integers n and m separated by a single space, 1 <= m <= n <= 100 - the parameters of the game, where n is the number of donuts in the box at the beginning of the game and m is the upper limit on the number of donuts to be taken by one player in one move.

输出格式


For each test case the output contains exactly one integer equal to the number of donuts Steve can count on.

输入输出样例

输入样例 #1

1
5 2

输出样例 #1

3