三号TLE,大捞捞一下!求求了!
#include <bits/stdc++.h>
using namespace std;
bool is_prime(int x)
{
if (x == 0)
{
return false;
}
if (x == 1)
{
return false;
}
for (int i = 2; i < x; i++)
{
if (x % i == 0)
{
return false;
}
}
return true;
}
int main()
{
int x, y;
cin >> x >> y;
if(x > y)
{
int temp;
temp = x;
x = y;
y = temp;
}
int cnt = 0;
for (int i = x; i <= y; i++)
{
if (is_prime(i)) cnt++;
}
cout << cnt;
return 0;
}