#include<bits/stdc++.h>
using namespace std;
const int maxn = 5e6;
bool isprime[maxn + 1];
int sieve(long long int a, long long int b) {
memset(isprime, true, sizeof isprime);
isprime[0] = isprime[1] = false;
for (int i = 2; i <= b; i++) {
if (isprime[i]) {
for (int j = i * 2; j <= b; j += i) {
isprime[j] = false;
}
}
}
int cnt = 0;
for (int i = a; i <= b; i++) {
if (isprime[i]) cnt++;
}
return cnt;
}
int main() {
long long int l, r;
cin >> l >> r;
int cnt = sieve(l, r);
cout << cnt;
return 0;
}
素数密度,求范围内素数个数,我的埃氏筛不能全过,为什么请修改