Winter came and the grasshopper didn’t have that much to eat. Unlike the ant of course... If at least it had collected something in the summer... It had to talk to the ant. Poor grasshopper. The ant had a bad reputation for speculation. It would certainly not give away anything. At most it would borrow some money!
And so it was. The ant lent it some money, but the grasshopper would have to pay everything back with interests. The ant would set the number of years for the reimbursement, and the grasshopper would pay a fixed amount along those years. The amount to pay in interests is recomputed every year, according to the amount still in debt at that moment in time. The difference between the fixed payment and the interests serves to amortize the debt. For example, assume that the Grasshopper borrows 100 at an interest rate of 5%, to be payed in 3 years. Then, we have the following payment plan (with values rounded to 3 decimal places):
Year | Debt | Payed | Interests | Amortization | |
1 | 100 | 36.721 | 5.000 | 31.721 | |
2 | 68.279 | 36.721 | 3.414 | 33.307 | |
3 | 34.972 | 36.721 | 1.749 | 34.972 | |
Totals | - | 110.163 | 10.163 | 100.000 |
Your task is to compute the total amount the grasshopper will pay to the ant (interests plus amortization). You will receive the number of years, the amount borrowed and the interest rate (in percentage).
The first line of the input is the number of instances to solve, n. In each of the following lines you will receive three values: the number of years, y, the amount borrowed, B, and the interest rate, r. The amount borrowed, B, and the interest rate, r, might not be integers.
1 ≤ n ≤ 1 000 | Number of cases |
1 ≤ y ≤ 100 | Number of years |
0 < B ≤ 1 000 | Amount borrowed |
0 < r ≤ 100 | Interest rate |
The output has one line per case, with the total amount payed to the Ant rounded to 3 decimal places.
1 3 100 5
110.163
4 20 100 6 15 1000 3 3 1.2 1.5 100 1000 100
174.369 1256.499 1.236 100000.000