Problem Code- SAKTAN

This is a problem regarding which I would like some help-

I have written a program to solve the given question. The link my solution is as follows-

My solution was able to solve two of the three tasks correctly. However, it failed in the case of the third task. It would be a great help if someone can explain where my code has gone wrong?

EDIT- I have solved the problem. Actually, the error was arising due to fact that variables a, b, d, e, f were declared as type int, as a result of which they were not able to hold larger sums. Therefore, I corrected it and changed the type of the variables to long long int

Link to new solution-

1 Like