#P17094. [ICPC 2017 Qingdao R] Collecting Cents
[ICPC 2017 Qingdao R] Collecting Cents
Problem Description
You have cents at the beginning, and there is a bank that accepts time deposits of your cents.
The time is measured in years and the interest rate is all the time. That is, if you make a time deposit of cents for years (both and must be integers), then after years, you can get back cents from the bank, where is the largest integer that is less or equal to . If you make multiple deposits, the interest of each deposit will be calculated independently.
You want to find the best strategy to deposit your cents such that the amount of cents you will own is maximized after years.
Input Format
The first line is the number of test cases up to 120. For each test case, there are three integers , and (, , , ).
Output Format
For each test case, output the maximum number of cents you will own after years.
3
3 2 4
5 6 5
1 1 63
14
10
9223372036854775808