Exceeding Time Limit - Working for Custom Inputs

#include
using namespace std;
int main() {
int t;
cin>>t;
for(int k=0;k<t;k++){
long long a; // long a;
long long b; // long b;
cin>>a>>b;
int cnt;
int pv =0;
for(int i=a;i<=b;i++){
cnt=0;
for(int j=1;j<=i;j++){
if(i%j==0){
cnt++;
}
}
if(cnt==2){
pv++;
}

	}
	cout<<pv<<endl;
}



return 0;

}

// Exceeding time limit - error. Rest 2 cases are passed.

@sahil112324 hey sahil sharma use sieve method which is discuss in number theory section.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.