var "last" is modified inside loop. It won't cross sqrt(n) .
Also I wanna know is there a faster algorithm ?
If n is prime last will never get updated..
Thanks . That did the job .from 1 min 5 secs to 2 secs on my test case .
Also what is common practice to reduce I/O overhead in such problems (with Large amount of IO). I pretty much use scanf printf .
I cant figure out what is wrong with my submission.Getting a WA