You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
494 B
C++

#include <cstdio>
#include <cstring>
using namespace std;
bool notPrime[3001];
int main()
{
memset(notPrime,0,sizeof(notPrime));
for(int i=2; i<3000; i++)
if(!notPrime[i])
for(int j=i*i; j<3000; j+=i)
notPrime[j]=true;
int x,y;
while(scanf("%d%d",&x,&y),x|y)
{
bool flag=true;
for(int i=x; i<=y&&flag; i++)
flag&=!notPrime[i*i+i+41];
puts(flag?"OK":"Sorry");
}
return 0;
}