2 shunfurh shunfurh 于 2017.09.18 17:42 提问

Loan

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 Kth 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)

1个回答

caozhy
caozhy   Ds   Rxr 2017.10.02 23:47
已采纳
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
Kaggle[1] - Loan Default Prediction - Imperial College London
比赛页面http://www.kaggle.com/c/loan-default-prediction
贷款承诺(Loan Commitment)
贷款承诺(Loan Commitment) 目录 ?1 贷款承诺的定义 ?2 贷款承诺的种类 ?3 贷款承诺的风险 ?4 贷款承诺与贷款意向的区别 ?5 贷款承诺申办条件 ?6 贷款承诺的期限   贷款承诺的定义   贷款承诺是指商业银行等金融机构作出的在一定期间内以确定条款和条件向承诺持有者(潜在借款人)提供贷款的承诺。1993年12月,美国联邦储备系统理事会发布修订后的
java中关于类、面向对象的简单介绍
类、面向对象
练手项目:loan_prediction问题
# -*- coding: utf-8 -*- import numpy as np import pandas as pd import matplotlib.pyplot as plt%matplotlib inlinedf = pd.read_csv('D:/my_project/Loan_Prediction/LoanPredictionProblem_train.csv') df.head
Matrix Computations, 4th Edition G.H. Golub and C.F. Van Loan
Matrix Computations, 4th Edition G.H. Golub and C.F. Van Loan
Common Mistakes Made By Online College Students
Trying to successfully earn your online degree can be challenging. There are a large number of pitfalls you will want to avoid, and a large number of students fail because of bad habits. Having said t
LOAN面向对向类程序
面向对象类的一个列子 Loan::Loan(double r,int y,double a){ annualInterestRate=r; numberOfYears=y; loanAmount=a; } Loan::Loan(const Loan& loan){ annualInterestRate = loan.annualInterestRate; numberOfYears = loan.numberOfYears; loanAmount = loan.loanAmount; } double Loan::getAnnualInterestRate(){ return annualInterestRate; } int Loan::getNumberOfYears(){ return numberOfYears; } double Loan::getLoanAmount(){ return loanAmount; } void Loan::setAnnualInterestRate(double rate){ annualInterestRate=rate; } void Loan::setNumberOfYears(int years){ numberOfYears = years; } void Loan::setLoanAmount(double amount){ loanAmount = amount; } double Loan::getTotalPayment(){ return annualInterestRate*loanAmount*numberOfYears+loanAmount; } double Loan::getMounthlyPayment(){ return getTotalPayment()/getNumberOfYears()/12; } void Loan::display( ) { cout<<"----计算列表----"<<endl; cout<<"利率:"<<getAnnualInterestRate()<<endl; cout<<"时间:"<<getNumberOfYears()<<endl; cout<<"金额:"<<getLoanAmount()<<endl; cout<<"月还款"<<getMounthlyPayment()<<endl; cout<<"总还款:"<<getTotalPayment()<<endl; }
XZ_iOS之App Store审核金融理财类被拒 3.2.1
在App Store上传金融理财类app被拒,被拒原因如下: We found that your app facilitates loan applications, but the seller and company names associated with your app do not reflect the financial institution in the app or
Loan default predictor(贷款违约预测)
Loan default predictor  (贷款违约预测) --- dylan at  2014-3-16   一:背景 Kaggle发布了一个涉及贷款违约预测的比赛,时间周期2个月(2014/01/17 -- 2014/03/14)。 其实,之前kaggle很久之前有过关于贷款相关信用预测的比赛。但是,这次和上次的情况很不同,挑战也更大。传统的金融相关的算法,其实是个典型二分类问
loan deal/loan facility
loandeal: bank give a loan to borrower LOANDEALID VERSION LDRDEALID LDRVERSION DEALSNPCUSIP DEALTYPE DEALNAME DEALDESC DEALSTATUS CRAGREEMENTDATE CRAGREEMENTCLSDATE CRAGREEMENTEF