http://codeforces.com/contest/80
A
1 #include<bits/stdc++.h> 2 using namespace std; 3 #define lson l,mid,rt<<1 4 #define rson mid+1,r,rt<<1|1 5 #define sqr(x) ((x)*(x)) 6 #define pb push_back 7 #define eb emplace_back 8 #define maxn 1000006 9 #define eps 1e-8 10 #define pi acos(-1.0) 11 #define rep(k,i,j) for(int k=i;k<j;k++) 12 typedef long long ll; 13 typedef unsigned long long ull; 14 15 16 int main(){ 17 #ifndef ONLINE_JUDGE 18 // freopen("input.txt","r",stdin); 19 #endif 20 std::ios::sync_with_stdio(false); 21 int n,m; 22 cin>>n>>m; 23 for(int i=n+1;;i++){ 24 int flag=1; 25 int j; 26 for(j=2;j<i;j++){ 27 if(i%j==0){ 28 break; 29 } 30 } 31 if(j==i) { 32 if(i==m) cout<<"YES"<<endl; 33 else { 34 cout<<"NO"<<endl; 35 } 36 break; 37 } 38 } 39 }