http://www.codechef.com/viewsolution/1964734

I haven’t solved a problem that asks to output the solution using mod.Please tell me where i went wrong in the logic.

http://www.codechef.com/viewsolution/1964734

I haven’t solved a problem that asks to output the solution using mod.Please tell me where i went wrong in the logic.

The logic is correct but it would run only for small values of N since you are using recursion. Also, as N increases, pow(26,N/2) would also increase and at one point of time you would start getting undesired values.

Instead, you should have computed power by exponentiation method.

You can also refer to my solution.

@skarthick : There is a previous thread which discusses mod related issues . You may find it useful .