Compound Interest II

Problem #8

Tags: computing statistics

Who solved this?

Previous:Compound Interest Next:Square Roots


Continuing from the previous problem with Jacob's investing...

While researching available savings bond options to invest in, Jacob encounters one bank with a particularly interesting offer. Fundamentally, an account opened with initial balance P will have a base interest rate of I and a compounding period of 1 year, but the investor may choose to divide both the interest rate and the compounding period by some integer C so that the actual account will have an interest rate of I / C and will compound C times per year.

Jacob begins to wonder to himself... Is there some value of C that could maximize his final earnings? The bank offer gives no limit to the size of C so potentially he could compound his balance every sub-millisecond! Could he potentially exploit the bank's offer to make a fortune?

Problem Statement

Input Data
First line will be Q, the quantity of testcases.
Q lines will then follow, each with three space-separated values in the format P I C, with P being the principal amount used to open the account, I being the base interest rate expressed as a decimal (for example 50% would be expressed as 0.5), and C being the quantity of compounding periods in a single year.

Answer
Should consist of Q space-separated values, corresponding to the amount of money in each account after 1 year.
Error should be less than 1e-3.

Example

input data:
3
100 0.1 1
200 0.1 10
300 0.1 100

answer:
110 220.924 331.535
You need to login to get test data and submit solution.