Getting TLE in my java solution using similar solution to others Accepted soulution.. plz Help

bytes4
easy-medium
gcd
sieve

#1

problem link

editorial link

my all submissions

all other users AC submission in java

plz someONe Help getting TLE exceed
i used same approach(algo) “sieve” as given above but geting TLE
I TRIED MY BEST TO OPTIMISE MYCODE TO GIVE AC BUT failed


#2

Time limit is too tight for this question (2*0.127796 ~ 0.25 seconds for java).
You can see my submissions–
https://www.codechef.com/status/BYTES4,vbt_95

I took same approach as you and got TLE. Even BufferedReader couldn’t avoid TLE.
Then i saw one submission of 0.14 seconds which used fastest method for reading input in java( refer https://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/ )
Got accepted by using same method for fast input with 0.13 seconds execution time.


#3

Thanks Bro, i did it using that 4th approach to take input… myTest Case passed in .09 seconds…(i guess fastest among all submited solution of java )…
thank YOu Very Much :slight_smile: