This page is still under construction.

Parts of this page are still being built. What you see may change.

Living Off the Interest

Time limit1sMemory limit1024 MB

Summary
Simulate monthly deposits and yearly compound interest to find how many years pass before the yearly interest exceeds yearly expenses.
Level

Medium6 of 10

Topics
Simulation, Math, Implementation
Solved
No attempts yet

Problem

On New Year's Eve, Juhan made himself a promise: right at the start of the coming year he will open a savings account, into which he will deposit DD euros at the end of every month. Juhan's net monthly salary — the amount he actually takes home each month — is PP euros. The bank pays interest of NN percent per year on the deposit. Juhan now wants to know how many more years he must keep saving before he can start living off the interest the bank pays him.

The bank pays interest once a year, on the last day of the year. If the interest is not enough to live on, Juhan puts the interest paid to him back onto the account that very same day. Juhan can live off the interest only once it exceeds his yearly expenses. For example, if Juhan earns 500500 euros a month and sets aside 200200 euros of it every month, then he needs at least 36003600 euros a year to live on.

On the money that was already in the account at the start of the year, the bank pays NN percent interest. On amounts added during the year, the bank pays interest for the number of whole months the money has been kept in the account (money added in December earns no interest, money added in November earns one month of interest, and so on). The interest rate MM for one month on deposit is computed as ((1+N100)112−1)⋅100%\left(\left(1 + \frac{N}{100}\right)^{\frac{1}{12}} - 1\right) \cdot 100\%. The interest rate for KK months is computed as ((1+M100)K−1)⋅100%\left(\left(1 + \frac{M}{100}\right)^{K} - 1\right) \cdot 100\%. The total interest for the year is rounded to the nearest cent and paid out to Juhan.

Input

The only line of input contains three space-separated real numbers PP, DD, and NN (P≤106P \le 10^6, 0<D<P0 < D < P, 0<N≤1000 < N \le 100). All numbers are given with a precision of at most 22 digits after the decimal point.

Output

Print a single integer: the number of years during which Juhan must still go to work.

Examples2

  1. Example 1

    Input
    300 240 10.1
    
    Expected output
    3
    
  2. Example 2

    Input
    500.00 200.00 5
    
    Expected output
    20