- shilinhan's blog
二级 找素数
- 2024-12-5 16:32:25 @
#include <bits/stdc++.h>
using namespace std;
int main() {
int a,b,cnt = 0;
bool isPrime = true;
cin >> a >> b;
for (int i = a;i <= b;i++) {
for (int j = 2;j <= sqrt(i);j++) {
if (i % j == 0) {
isPrime = false;
}
}
if (isPrime) {
cnt++;
} else {
isPrime = true;
}
}
cout << cnt;
return 0;
}