I have submitted these two codes first and second where first once works and second doesn’t. It caused me two runtime errors. I guess the input file contains some extra spaces. Correct me if i’m wrong. If it contains extra spaces then how to deal with that using the second code.
use getchar() after taking n as input…bcause when u press “enter” after taking n as input gets() function take it as a string, that’s whu u r getting rte…
do it like this
n = readInt();
Same problem with this program http://www.codechef.com/problems/LUCKY5. But in this case we have to check for digits.
Actually, the readInt() function already deal with this case. And it is working fine with other codechef problems.