Submit | All submissions | Best solutions | Back to list |
PRIMEEXP - The Prime Explorer |
Mr. Prime loves to travel around the World and explore all the countries. His new year resolution is to travel around the globe with his favourite bicycle. He has already made a detailed plan for his tour. Along the way, Mr. Prime wants to take a break after every few miles, but true to his name, he only stops after travelling for a prime number of miles. So, for example, he can stop at a city which is 71 miles away from the start but will not stop if the city is 100 miles away.
The mayor of your city heard that Mr. Prime will be passing his city and he wants give him a warm reception. But he is not sure if Mr. Prime is at all going to stop in the city. So, as a renowned programmer, he is asking for your help. He has already collected information about Mr. Prime’s travel plan and he would provide that information to you. In return, you have to tell him whether Mr. Prime is going to stop at any point within the city boundary.
You will be provided two integer numbers A and B where A is the number of miles Mr. Prime would have travelled when he enters the city and B is the number of miles he would have travelled when he leaves the city. We will consider him to be in the city even if he is exactly at the border. You need to tell the Mayor whether or not Mr. Prime will stop in the city at all.
Input
There will multiple lines where each line represents one test case. For each test case there are 2 space separated integers A and B in a single line. These numbers follow the restriction 2 < A ≤ B < 2^64 and B-A ≤ 100. The input is finished when EOF is reached.
Output
For each test case output either “YES” or “NO” on a single line.
Example
Input: 5 13 91 95 49 53 75 77 Output: YES NO YES NO
Explanation
For the first case 5, 7, 11, 13 all are prime numbers within the range.
For the second case there is no prime number in the range from 91 to 95.
Similarly, for the third case, 53 is a prime number and for the last case there is no prime number between 75 and 77.
Problem Setter: Md Imrul Hasan
Added by: | Najmuzzaman |
Date: | 2015-04-08 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 JS-MONKEY |