水题水题
#include<cstdio>
#include<vector>
#include<cstring>
#define _for(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(i, a, b) for(int i = (a); i < (b); i++)
using namespace std;
const int MAXN = 1123456;
bool is_prime[MAXN];
vector<int> prime;
int ans[MAXN];
void get_prime()
{
memset(is_prime, true, sizeof(is_prime));
is_prime[0] = is_prime[1] = false;
REP(i, 2, MAXN)
{
if(is_prime[i]) prime.push_back(i);
REP(j, 0, prime.size())
{
if(i * prime[j] >= MAXN) break;
is_prime[i * prime[j]] = false;
if(i % prime[j] == 0) break;
}
ans[i] = ans[i-1] + is_prime[i];
}
}
int main()
{
get_prime();
int n, m, l, r;
scanf("%d%d", &n, &m);
while(n--)
{
scanf("%d%d", &l, &r);
if(l < 1 || r > m) puts("Crossing the line");
else printf("%d
", ans[r] - ans[l-1]);
}
return 0;
}