WA , TLE in NOLOGIC!

http://www.codechef.com/viewsolution/5546716-this solution gives me WA but on replacing scanf(“%d”,&t) with ’ int v;char t[320];
gets(t);
v=atoi(t);’ I got CA.
Also CodeChef: Practical coding for everyone is giving TLE though this seems to be a faster solution to me

I think so problem is with atoi(), and btw int cannot store a number with length 314 decimal numbers also you are declaring array of int datatype and storing characters in it.

I might be wrong…

Go through this Link : atoi function in C not working properly (when exceeding a certain value) - Stack Overflow

nice link thanks :slight_smile:
but the length of t is not 314 is it?
then why the problem?

Okay i am sorry i am unable to figure it out the reason for TLE but for the code you are getting WA i got the bug.

while taking integer input ‘\n’ is left in buffer and when you take input in str variable ‘\n’ is stored instead of he actual string, Thus you have to take ‘\n’ as dump input as so use getchar() after scanf() and you’l receive AC.

Just check this AC link i have submitted using your code by adding getchar():

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

thank u so much!

1 Like

welcome…:slight_smile: