```
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 1000010;
int primes[N], cnt;
bool st[N];
void get_primes(int n)
{
for (int i = 2; i <= n; i ++ )
{
if (!st[i]) primes[cnt ++ ] = i;
for (int j = 0; j < cnt && i * primes[j] <= n; j ++ )
{
st[primes[j] * i] = true;
if (i % primes[j] == 0) break;
}
}
}
int main()
{
int t , s;
cin>>t>>s;
for(int u=1;u<=t;u++){
int ans=0;
int k;
int n;
cin >> k>>n;
if(k<1 || n>s){
cout<<"Crossing the line"<<endl;
continue ;
}
get_primes(n);
for(int u=k;u<=n;u++){
if(st[u]==false&&u!=1){
ans++;
}
}
cout<<ans<<endl;
}
return 0;
}
```
by YmloveYs @ 2019-01-30 09:05:31