Having Problem with DYNAMO

My code is giving correct output for each test case according to me but it is giving wrong answer verdict in only one test case out of four test cases. Can someone point out the the problem with my code.
Solution link -CodeChef: Practical coding for everyone

Avoid the pow() and use some alternate.

can you please explain the reason why pow() should be replaced with some alternate?

try out t=1, a=1, b=99, d=99

pow() function returns floating value.
So it might return pow(5,2) as 24.999 which gets rounded off to 24 for int.

Output:-
201
1
1

oops i just missed out on value of n,
Yea, the possible error is due to conversion from double to long long while calculating power

How to deal with this issue?

best way is to define your own power() to calculate the power