Kth root hackerblocks

Problem - https://hack.codingblocks.com/contests/c/512/274
My solution - https://ide.codingblocks.com/s/43244

I am passing the sample test case but failing all three submission cases.

you are not passing sample test case.
1
1000000000000000 10
and

reason : val = pow(mid, k); datatype of val is unsigned long long as mid and k could be very large and will cross the long long range and the time when it cross the long long range , val will become zero and ur answer answer will become mid.

Hit like if u get it

1 Like

what @Anubhav-Aron-1353657 + :

you can not calculate mid^k (for large mid this will be beyond limits ) so wrong ans.
Tip: pow function work only for int data type.

Cheers!

1 Like

https://ide.codingblocks.com/s/44396
How can i optimise this code ?
in the sample case given, first test is passing but second shows runtime error.

Hey Akshay, there is no need to to make a vector of size n it will leads to run time error as n will be very large,