Last 3 test cases - wrong answer

Question: https://hack.codingblocks.com/app/practice/1/300/problem

My answer: https://ide.codingblocks.com/s/414369

In the video, Prateek bhaiyya explained the approach, and this is my implementation based on that approach.

Test case - 0,1,2 - correct answer
Test case - 3,4,5 - wrong answer

Declare all variable as long long int and then try to submit.
It’s cause of constraints you might be failing. If this doesn’t work. Let me know.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

@mr.encoder Thanks! It worked.
Can you please explain why it wasn’t working for simple int data-type? so that I won’t repeat this mistake.

See the value of constraints, they are in 10^9 , so to store such large value. We take long long int.

@mr.encoder Like always didn’t care about constraints, and started coding right away. Thanks for pointing it out to me.