what is wrong ?

June Cook-Off 2018 Division 2 Archi and Comparsion


i get answer correct when i compile but its wrong answer here

Using pow(a,n) will definitely overflow int, since a and n, both were upto 10^9. While this may work for small inputs, it will fail for bigger inputs.

Consider a = 2, b = 3, n = 30

According to your solution,

c = a^n = 1073741824
d = b^n = -2147483648 (print 'd' in your solution)

therefore c > d

But you can clearly see that 2^30 < 3^30. Read about integer overflows in the link above.

The best way to do the task is just to divide the flow based on the odd or even n is.
And then use abs() if we have n = 2,4,… or the values itself otherwise.