Approach : Precomputation as discussed in editorial
→ nPrime[ i ] stores the count of primes till i (inclusive)
Here is the link :
https://www.codechef.com/viewsolution/47345495
Apart from helping with the logic, u can also suggest me how to improve code quality, or a shorter/smarter way to do any task.