https://ideone.com/XTJ2Sn … where am i going wrong https://www.spoj.com/problems/ABA12D/
I don’t think your logic is right.
Try these:
2 1 40 1 1000000
My Ac code gives
5 37
Thank you.I’ll check.