Bank Loan 2

Xem dạng PDF

Gửi bài giải

Điểm: 1,00 (OI)
Giới hạn thời gian: 1.0s
Giới hạn bộ nhớ: 256M
Input: stdin
Output: stdout

Nguồn bài:
Hà Minh Ngọc
Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch

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 < 10^{12}, 0 < N ≤ 500, X/N + X*r/12 ≤ Y < 10^{12}, 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 1

1200 300 12 12 1

Sample Output 1

1 914
2 626
3 335
4 41
5 0

Sample Input 2

1000000000 95000000 12 6 3

Sample Output 2

1 910194175
2 820140918
3 729846236
4 639315987
5 548555890
6 457571524
7 366368332
8 274951625
9 183326585
10 91498270
11 0

Explain:


Bình luận

Hãy đọc nội quy trước khi bình luận.


Không có bình luận tại thời điểm này.