PRIME1

Solution 1

Solution 2

I used the sieve of Eratosthenes in the first solution. I checked each number in the range [1, n]. I printed the primes which were greater than or equal to m. I got a TLE.

I realized that I only have to check each number in the range [m, n]. So I checked them with the O(sqrt(n)) technique. It still gave a TLE. What approach should I use?

Just change long long to int

1 Like

It worked. Thanks .