為何一直TLE?
麻煩告訴我~謝謝!!
#include <stdio.h>
#include <math.h>
int main()
{
int a = 0, b = 0, cnt = 0, count = 0 ;
while(scanf("%d", &a) != EOF)
{
scanf("%d", &b);
cnt = 0, count = 0;
for(int x = a ; x <= b ; x++)
{
cnt = 0;
//printf("\nx = %d\n", x);
if(x == 1)
count--;
if(x == 2)
count++;
else
{
int cc = sqrt(x);
for(int y = 1 ; y <= cc ; y++)
{
//printf("y = %d\n", y);
if(x % y == 0)
{
cnt++;
//printf("cnt = %d\n", cnt);
}
}
if(cnt == 1)
{
count++;
//printf("count = %d\n", count);
}
}
}
printf("%d\n", count);
}
return 0;
}