TLE in PRETNUM

It Is a very strange error. I have given max test cases each worst possible getting a runtime of 0.37 on ideone. The time limit is (1-2) still getting tle.One of the accepted solutions was run by me on the same test cases and my code was abt 2x faster for a test case(extreme). In the mail received from codechef my codes’ run time was given as 1.20 and status tle. The problem clearly specifies 1-2 sec.
What could be the problem? Please help me out if anybody knows the cause.I will provide the links of the codes if i get response.

Check your code for
1
999999000000 1000000000000

the approach you are using is taking time and that is causing you a TLE.
Solutions are available now try something else that runs faster.
If you want you can use this property— c - finding number of numbers which have prime number of factors - Stack Overflow

view my solution — CodeChef: Practical coding for everyone

http://discuss.codechef.com/questions/28909/pretnum-editorial

5 Likes

Thanx laxman94 for answering. I ran my solution for the test code for your test case. Ran in 0.07 sec. even when 5 cases are given like this, it took 0.36 seconds.I have got tles before but this one baffles me.

Your code btw took 0.12 sec on ideone for the same case.
js1rMM - Online C Compiler & Debugging Tool - Ideone.com <— Your code
p5tDP5 - Online C++ Compiler & Debugging Tool - Ideone.com<— my code
The answer might be different. but why the tle.

If it isn,t giving the right answer then why are you trying to optimize it. First correct the solution then think of correcting it first…

2 Likes

And you are talking about your code hmm…
look at this when i tried fifty test cases → oGqrOA - Online C++ Compiler & Debugging Tool - Ideone.com <-my code was able to do in 2.74 sec.

and your code couldn’t even do it in 5 seconds, then i raised it to 15s it was able to do it in 5.34 seconds.-> A4BRfV - Online C++ Compiler & Debugging Tool - Ideone.com

And the input file these guyz are using is not something with 4-5 test cases.

About my code it took only 0.43 sec during the contest. Comparing with such a solution after checking for 2-3 inputs may sound insane according to me.

2 Likes

I thought when they specify the no of test cases, they are ->not<- being funny there. For test cases upto limit of five my code was feasible so i did that. Thanx a lot bro nyws!