Problem | Verdict | Lang | Time | Best | Rank | Submit Time |
---|---|---|---|---|---|---|
| discuss10114 - | Accepted | Python | 0.020 | 0.000 | 5752 | 1 mins ago |
Suggest:
You only need forcus: (for output 1)
Consider the first example below of borrowing $15,000 for 30 months. As the buyer drives off the
lot, he still owes $15,000, but the car has dropped in value by 10% to $13,950. After 4 months, the
buyer has made 4 payments, each of $500, and the car has further depreciated 3% in months 1 and 2
and 0.2% in months 3 and 4. At this time, the car is worth $13,073.10528 and the borrower only owes
$13,000
AND note
month_pay = loan / months (15000 / 30 = 500)
I lost many time because think down_payment is month_payment ($500)
while True:
months, down_pay, loan, n = map(float, input().split())
months = int(months)
n = int(n)
if months < 0:
break
depreciations = [-1]*(months+1)
for _ in range(n):
month, depreciation = map(float, input().split())
month = int(month)
depreciations[month] = depreciation
car_money = (down_pay + loan)*(1-depreciations[0])
owe = loan
if (owe < car_money):
print("0 months")
else:
month_pay = loan / months
for i in range(1, months+1):
if depreciations[i] == -1:
depreciations[i] = depreciations[i-1]
owe -= month_pay
car_money -= car_money * depreciations[i]
if (owe < car_money):
if (i>1):
print(i, 'months')
else:
print(i, 'month')
break
# 30 500.0 15000.0 3
# 0 .10
# 1 .03
# 3 .002
# 12 500.0 9999.99 2
# 0 .05
# 2 .1
# 60 2400.0 30000.0 3
# 0 .2
# 1 .05
# 12 .025
# -99 0 17000 1
No comments:
Post a Comment