22641_Loan

2022-5-16 18:22| 发布者: Hocassian| 查看: 20| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-5-89506812548800-Problem List-采集的数据-后羿采集器.html

Pro.ID

22641

Title

Loan

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=22641

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 1000/500 MS (Java/Others)     Memory Limit: 32768/32768 K (Java/Others)
  • 描述

    Mr. Smith received a loan for Q dollars. He plans to pay off this loan in K years at an interest rate of P percent per year. That means that, after each year, Mr. Smith's debt grows by P × Q'/100 dollars (Q' being the debt at the beginning of that year) and his annual payment is deducted from his debt.

    For the first year, Mr. Smith wants to pay minimal amount that will allow him to pay off the loan within exactly K years. For each subsequent year, he is willing to pay either the same amount as the previous year or one cent less than the previous year's payment. He wants the loan to be completely paid off without overpayment of even a single cent by the end of the K-th year.

    The bank performs all transactions with a precision of one cent, and calculates interest due at the end of each year. Whenever interest is calculated, the result is immediately rounded to the nearest cent, with 0.5 cents rounded up.

    输入

    The input contains a single line with three numbers Q, P and K, separated by spaces. Q is a real number ( 10 ≤ Q ≤ 1000000 ) given with no more than two digits to the right of the decimal point. This value represents the amount of the loan in dollars. One one-hundredth of a dollar is a cent. P and K are integers ( 0 ≤ P ≤ 100, 1 ≤ K ≤ 100 ).

    输出

    Description

    Mr. Smith received a loan for Q dollars. He plans to pay off this loan in K years at an interest rate of P percent per year. That means that, after each year, Mr. Smith's debt grows by P × Q'/100 dollars (Q' being the debt at the beginning of that year) and his annual payment is deducted from his debt.

    For the first year, Mr. Smith wants to pay minimal amount that will allow him to pay off the loan within exactly K years. For each subsequent year, he is willing to pay either the same amount as the previous year or one cent less than the previous year's payment. He wants the loan to be completely paid off without overpayment of even a single cent by the end of the K-th year.

    The bank performs all transactions with a precision of one cent, and calculates interest due at the end of each year. Whenever interest is calculated, the result is immediately rounded to the nearest cent, with 0.5 cents rounded up.

    Input

    The input contains a single line with three numbers Q, P and K, separated by spaces. Q is a real number ( 10 ≤ Q ≤ 1000000 ) given with no more than two digits to the right of the decimal point. This value represents the amount of the loan in dollars. One one-hundredth of a dollar is a cent. P and K are integers ( 0 ≤ P ≤ 100, 1 ≤ K ≤ 100 ).

    Output

    Write to the output file a schedule of payments for Mr. Smith. You should write the amount of each payment and number of years that payment should be made, thus effectively grouping equal payments. Each group of equal payments must be written on separate line, with no blank lines between them. The output format for each group of payments is:

    $X for Y year(s)

    where X is payment amount in dollars printed with exactly two digits after decimal point. Y is a number of years for which this payment should be made. The dollar value given on each line must be one cent less than the dollar value printed above it.

    If there are multiple correct payment schedules, you can output any one of them, but the first payment should be the minimal possible one. If no solution can be found for the given input, then the output file shall contain only the word "Impossible".

    Sample Input

    939850.83 85 35

    Sample Output

    $798873.22 for 1 year(s)
    $798873.21 for 1 year(s)
    $798873.20 for 1 year(s)
    $798873.19 for 1 year(s)
    $798873.18 for 1 year(s)
    $798873.17 for 4 year(s)
    $798873.16 for 1 year(s)
    $798873.15 for 2 year(s)
    $798873.14 for 1 year(s)
    $798873.13 for 3 year(s)
    $798873.12 for 1 year(s)
    $798873.11 for 4 year(s)
    $798873.10 for 2 year(s)
    $798873.09 for 7 year(s)
    $798873.08 for 2 year(s)
    $798873.07 for 1 year(s)
    $798873.06 for 1 year(s)
    $798873.05 for 1 year(s)

    Source

    样例输入

    939850.83 85 35

    样例输出

    $798873.22 for 1 year(s)
    $798873.21 for 1 year(s)
    $798873.20 for 1 year(s)
    $798873.19 for 1 year(s)
    $798873.18 for 1 year(s)
    $798873.17 for 4 year(s)
    $798873.16 for 1 year(s)
    $798873.15 for 2 year(s)
    $798873.14 for 1 year(s)
    $798873.13 for 3 year(s)
    $798873.12 for 1 year(s)
    $798873.11 for 4 year(s)
    $798873.10 for 2 year(s)
    $798873.09 for 7 year(s)
    $798873.08 for 2 year(s)
    $798873.07 for 1 year(s)
    $798873.06 for 1 year(s)
    $798873.05 for 1 year(s)

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部