i dont know where my code fails.There must be any corner case.Please let me know where my code fails. thanks in advance... //question link http://www.codechef.com/status/CDM03/ //solution link http://ideone.com/7Y0SGE asked 31 Dec '14, 16:24

Try these,
Using inbuilt power pow function for such large computations give erroneous results. Try some other logic(there exists an easy one by just finding the cycle of the last digit of a example: 8^any power, after how many computations we get 8 as the last digit of our answer again) or some other way for computing power. There exists a logn method also. You may like seeing here.. answered 31 Dec '14, 16:40

You are using the pow function which is creating problems.The range of the answer of a^b is very large and int cannot hold such large (even long long int cannot hold such numbers). You should try to calculate just the last digit not the whole answer. Check here your code is giving wrong answer. answered 31 Dec '14, 16:43
thanks for pointing out... thanks a lot
(31 Dec '14, 16:54)
Welcome :) if it helps please upvote and accept it as correct answer ;)
(31 Dec '14, 17:14)
i wish i could upvote but i have less reputation but i will certainly accept it as correct answer.. :)
(31 Dec '14, 17:57)
Thanks I didn`t notice that!!! Happy Coding !!!
(31 Dec '14, 18:46)

As other's have told you where is your mistake,I won't be pointing it out again.But would rather like to give you a hint for solving this one.Try to store the result in an array.Now question arises How?? answered 31 Dec '14, 19:24

Open the calculator program on your PC, try calculating the first few powers of any number (While looking at the last digit of the result), do you notice something ? answered 31 Dec '14, 18:02
