TLE in One Test Case
Number of test cases is also 10000 and u r applying loop to 1000000. So rather than applying loop, make a prefix sum count which determines upto i index how many primes are before this and then apply binary search to find the lower_bound to find the index in logn … Do that prefix sum calc before test case loop.
Hello! I couldn’t understand the exact the problem. Even if the test cases are around 10,000 the loop would be running separately for each case. How is this a probloem?
Time limit is calculated for the whole program … With test cases included so if there are 10000 test cases multiply them too.