题目:
https://acm.hdu.edu.cn/showproblem.php?pid=2012
知识点:
#include<stdio.h>
int main()
{
int x,y,t,num,sum,k;
while(scanf("%d%d",&x,&y)!=EOF)
{
t=1;//为素数,不进循环;t用来区分是否为素数
if(x==0&&y==0)
{
return 0;//x=0,y=0,该行不做处理
}
else if(x>=-39&&x<y&&y<=50)
{
for(num=x;num<=y;num++)
{
sum=num*num+num+41;
for(k=2;k<t/2;k++)
{
if(t%k==0)
{
t=0;
break;
}
}
}
if(t==1)
{
printf("OK\n");//素数
}
else if(t==0)
{
printf("Sorry\n");//不是素数
}
}
}
return 0;
}