Prime visits(((())))

my two test cases are passing but third ne is showing TLE
PMO gives two random numbers a & b to the Prime Minister. PM Modi wants to visit all countries between a and b (inclusive) , However due to shortage of time he can’t visit each and every country , So PM Modi decides to visit only those countries,for which country number has two divisors. So your task is to find number of countries Mr.Modi will visit.
#include
using namespace std;

define long long int;

int32_t main() {
int t;
cin>>t;
while(t–){
int s,e;
cin>>s>>e;

	int no,i, count =0;
	for( no=s;no<=e;no++){
		for( i=2;i<no;i++){
			if(no%i==0){
				break;
			}
		}
		if(i == no){
			count++;
		}
	}

cout<<count<<endl;

}
return 0;

}

hi @abhinavssr2003_eab0717682969e5c,
if you’ll do by this method you’ll get TLE use sieve method
first calculate all the prime no then make a cumulative sum array
now each query can be answered in o(1)

for code refer here : https://ide.codingblocks.com/s/660590