I received many TLEs for this problem:
- Make sure you pre-compute enough primes ahead using Sieve of Eratosthenes
- Pay attention to the way you compute the primes (my original implementation was slow).
I also received two WAs because of how I was rounding the result:
- For some reason my rounding idea (commented in the code) didn't work, I googled the problem and I corrected my output.