Buying Car

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

Dạng bài
Ngôn ngữ cho phép
C, C++, Java, Kotlin, Pascal, PyPy, Python, Scratch

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 financial conditions of both the old and new cars, determine the minimum number of months required before you can sell the old car, pay off the remaining loan, and afford the down payment for the new car without needing extra money.

For example,

  • Old car price: $50,000
  • Down payment: 20% of $50,000 = $10,000
  • Loan term: 60 months
  • Annual interest rate: 4.8% → Monthly interest rate: 0.4%
  • Monthly depreciation rate: 1.67%
  • New car price: $50,000

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 (0 < m < 100)
  • n - Loan term in months
  • R - Annual interest rate (percentage)
  • L - Monthly depreciation rate (percentage)

Output

Print the minimum number of months required before you can sell the old car, pay off the remaining loan balance, and make the down payment for the new car without requiring additional money. If customer cannot make a down payment for the new car after the period of given months, print the amount of additional money.

Example

Input
50000 50000
20 60 4.8 1.67
Output
45 0

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.