Wrong answer in RRECIPE

Can anyone tell me why am i getting wrong output in RRECIPE question?
Question link : RRECIPE Problem - CodeChef
Solution link :CodeChef: Practical coding for everyone

Hey…

I think you should read the problem statement (Especially under the heading OUTPUT) once again

The only problem I can see in your code is that you needed to print answer modulo (10^7)+9. But this modulo part seems missing in your code.

Since variable ctr can go very large when it is becoming 26 raised to power something on every iteration, I would advice you to initialize variable ctr as ‘long long’ data type and apply this modulo thing on every updation of variable ctr.

This is corrected version of your code.

Also, just as an extra piece of advice… line number 15 and 16 in your code does not make sense, because even if that case executes, you are multiplying ctr by 1. (Obviously a number multiplied with ‘1’ wont change it). Hence you may remove that.

I hope this helps… Happy Coding… :slight_smile:

1 Like