题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2012
算法特工队QQ群:979618872 (伸手党绕边,欢迎有良好基础的人加入)
//
// Created by Leo Lee on 2019/4/3.
//
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;
bool isprime(int n);
int main(){
int x,y;
while(cin>>x>>y&&(x!=0 || y!=0)){
if (x>y)
swap(x,y);
bool sign = true;
for(int i = x;i<=y;i++){
int z = i*i+i+41;
if(!isprime(z)){
cout<<"Sorry"<<endl;
sign = false;
break;
}
}
if (sign)
cout<<"OK"<<endl;
}
}
bool isprime(int n){
for(int i = 2;i<=(int)sqrt(n);i++){
if(n%i == 0)
return false;
}
return true;
}