This was an easy problem. But I fell into the trap thinking that, down payment = monthly payment
. But The monthly payment is loan_payment / number_of_months
. In the first test case, it just happens to be,
\[ \frac{15000}{300} = 500 = \textrm{Monthly Payment} = \textrm{Down Payment} \]
In the second test case, Monthly_payment != Down_Payment
. Once this fact is understood, the rest boils down to just simulating the process. Following is my C++
solution:
Another thing to watch out for is the output format. I got a silly WA
by printing $\text{0 month}$, where in the problem statement it was clearly mentioned to output months
in all cases expect $1$.
Sharing is caring. Share this story in...
Share: Twitter Facebook LinkedIn