Submit | All submissions | Best solutions | Back to list |
EIUCARLOAN2 - Car Loan 2 |
In the United States, cars are often purchased through financing. When buying a car, a customer makes an initial down payment, and the remaining cost is financed through a loan. The loan is repaid over a fixed number of months with a fixed monthly payment that includes both principal and interest.
Additionally, cars lose value over time. The moment a car is purchased, its value immediately drops to 90% of its original price. After that, it continues to depreciate by a fixed percentage each month.
You own an old car and want to buy a new one. Given the prices, loan term, the point in time when selling the car would allow full repayment of the remaining loan and making a down payment on a new car, and monthly depreciation rate, determine the annual interest rate required so that after a certain number of months, you can sell your current car, pay off the remaining loan balance, and still afford the down payment for the next car without needing any extra money.
For example,
- Old car price: $50,000
- Down payment: 20% of $50,000 = $10,000
- Loan term: 60 months
- The point in time when selling the car would allow full repayment of the remaining loan and making a down payment on a new car: 45 months
- Monthly depreciation rate: 1.67%
- New car price: $50,000
With the annual interest rate of about 3.95%, after 45 months, the car is worth $21,090. At this point:
- Remaining loan balance is $10,954
- You can pay the loan off and still have enough for the $10,000 down payment on the new car.
Input
You will be given:
● P – Initial price of the old car (dollars)
● New_P – Price of the new car (dollars)
● m – Down payment percentage (m ≤ 100)
● n – Loan term in months
● k – The point in time when selling the car would allow full repayment of the remaining loan and making a down payment on a new car
● L – Monthly depreciation rate (percentage)
Output
Print the minimum annual interest rate rounded to 4 decimal places
Sample
Input |
Output |
50000 50000 20 60 45 1.67 |
0.0395 |
100000 120000 20 60 58 2.0 |
0.0462 |
Added by: | Ha Minh Ngoc |
Date: | 2025-08-30 |
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 |