Submit | All submissions | Best solutions | Back to list |
EIBANKLOAN3 - Bank Loan 2 |
Mr. Huy wants to buy a new car worth X VND, so he decided to take out a bank loan with an interest rate of r% per year for N months. He calculates that he could pay a maximum of Y VND per month (includes principal and interest). However, if he pays his loan off early, he will be charged a prepayment penalty fee f%. Your task is to write a program to calculate loan balance every month until the loan balance is 0 (which means he finally pays off the loan).
* Prepayment penalty fee = f% * amount of prepay
Input
The only line contains 3 integers X, Y, N and 2 real numbers r, f (0 < X < 1012, 0 < N ≤ 500, X/N + X*r/12 ≤ Y < 1012, 0 < r ≤ 15, 1 ≤ f ≤ 3).
Output
For each month, output the index and the loan balance (rounded to the nearest integer).
Note: Only rounded to show result, not rounded while calculating.
Sample
Input |
Output |
1200 300 12 12 1 |
1 914 2 626 3 335 4 41 5 0 |
1000000000 95000000 12 6 3 |
1 910194175 2 820140918 3 729846236 4 639315987 5 548555890 6 457571524 7 366368332 8 274951625 9 183326585 10 91498270 11 0 |
Explain: https://docs.google.com/spreadsheets/d/1If7TofhSS-Q2trCc09E7iLl7DMZ7gnEhC-IECwChJ2I/edit#gid=0
Note for testcase 1: In the first month, Huy has to pay 12 for interst, 100 for standard monthly payment. There are 188 left that he want to pay, so he prepay 186.1386 plus 1% of it as penalty,
Added by: | Ha Minh Ngoc |
Date: | 2022-12-25 |
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 |