Little Bob loves chocolate, and he goes to a store with $N in his pocket. The price of each chocolate is $C. The store offers a discount: for every M wrappers he gives to the store, he gets one chocolate for free. How many chocolates does Bob get to eat?

**Input Format:**

The first line contains the number of test cases, T.

T lines follow, each of which contains three integers, N, C, and M.

**Output Format:**

Print the total number of chocolates Bob eats.

**Constraints:**

1≤T≤1000

2≤N≤105

1≤C≤N

2≤M≤N

**Sample input**

```
3
10 2 5
12 4 4
6 2 2
```

**Sample Output**

6

3

5

class Chocklate_Feast_Hackerrank

{

static void Main(String[] args)

{

int cases = int.Parse(Console.ReadLine());

for (int i = 0; i < cases; i++)

{

int[] temp = Console.ReadLine().Split(‘ ‘).Select(x => int.Parse(x)).ToArray<int>();

int total = temp[0] / temp[1];

int wrappers = total;

while (wrappers >= temp[2])

{

int temp2 = wrappers / temp[2];

total += temp2;

wrappers = (wrappers – (temp2 * temp[2])) + temp2;

}

Console.WriteLine(total);

}

Console.ReadLine();

}

}

### Like this:

Like Loading...

*Related*