Submit | All submissions | Best solutions | Back to list |
EIUPASSBOOK - Passbook Withdrawal |
Nam has a passbook (sổ tiết kiệm) of X VND with an interest rate of r1% per year and a term of n months. Interest is calculated at the end of the term. After m months (m < n), Nam wants to withdraw money from the passbook to build a house. After researching, Nam has discovered two options:
- Option 1: settle the passbook and receive only the full principal amount.
- Option 2: Use the passbook as collateral (passbook loan) to borrow money from a bank with a value of Y VND and an interest rate of r2% per year. Interest is calculated annually (if n – m ≥ 12), or until the passbook is settled at month n. Note that in this case, Nam will use all amount of money he receives from his passbook after month n to pay off this loan.
Calculate the maximum amount of money Nam can withdraw from the passbook (X) or borrow from the bank (Y).
Input
The only line contains 3 integers X, n and m, followed by 2 real numbers r1 and r2 (0 < X ≤ 1015, 0 < m < n ≤ 300, 0 < r1, r2 ≤ 20).
Output
The maximum amount of money (rounded to unit).
Sample
Input |
Output |
100000000 12 10 7 8.5 |
105505341 |
100000000 12 2 7 8.5 |
100000000 |
Added by: | Ha Minh Ngoc |
Date: | 2023-06-14 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | CSHARP C++ 4.3.2 CPP CPP14 CPP14-CLANG FSHARP GO JAVA JS-MONKEY NODEJS PHP PYTHON PYPY PYPY3 PYTHON3 RUBY SQLITE SWIFT VB.NET |