MGCSET C++ power function issues HELP

Here is link to problem : https://www.codechef.com/problems/MGCSET/

I noticed one unusual thing with inbuilt power function being used with cout directly giving WA. While if result to be printed is first stored in variable, it is giving AC.

User defined implementation of power function works fine. Can anyone point out why library power function is giving wrong answer?

Some resources will be appreciable if any.

Links to my solutions :

  1. https://www.codechef.com/viewsolution/24951293
  2. https://www.codechef.com/viewsolution/24951297
  3. https://www.codechef.com/viewsolution/24951323

1(Partial) and 2(AC) has only one line difference in cout line. 3(AC) is similar to 1 but with user defined power function which is working well.

only reason could coz they expect ans in int format and by directly printing cout its either printing in double or in scientific notation
I hav a feeling that its due to 2nd reason
for large num ur ans will look like this ‘10e+7’ cos pow returns double and thats how double values are stored

3 Likes