1572 - Jeep Plus

Time Limit: 1s Memory Limit: 128MB

Submissions: 19 Solved: 10
Description
    Our jeep is in the desert and we have a hard task: First we must reach a point which is N kilometers away from our camp, and then return to our camp. The terrain is tough, the car is old, and it seems like the fuel flows out, and because of this on every kilometer travelled, one litre of fuel is spent. But the jeep only has fuel tank with total capacity of M < N litres. On other hand, there is unlimited amount of fuel at our camp, and there are empty fuel tanks everywhere in the desert, these fuel tanks are large enough. When the jeep is passing near these fuel tanks, it can leave unlimited amount of fuel to them, or take unlimited amount of fuel from them to the jeep’s fuel tank.
     Write a program which calculates the minimum amount of fuel in litres which is needed to reach the destination point and return to home.
Input
    The input consists of multiple test cases.
    The first line contains a number T, the number of the cases.
    In the next T lines, every line contains two integers N and M. It is known that 5*M >= N > 0.(N <= 32000).
Output
      For each test, write a single line contains the result (the minimum litres of fuel, eventually rounded up), must be written on the only line of output.
Sample Input
2
3000 1000
32000 6400
Sample Output
226009
79145396
Hint
Source
Sheng NI