Twin Apparent Primes
Time Limit: 10 Seconds Memory Limit: 65536 KB
Prime numbers have very interesting applications in Computer Science. This problem is obviously related with prime numbers but you need to know the following two definitions to solve this problem.
Apparent Prime: A positive number that is not divisible by all integer numbers greater than 1 and less than or equal to t is called apparent prime. The value of t will be supplied for you.
Twin Apparent Primes: If the difference of two apparent primes is 2 then they are called twin apparent primes.
Given the value of n and t you will have to find two n-digit apparent prime numbers p and (p+2).
Input
The input file contains at most 1001 lines of inputs. Each line contains two positive integers n (3500 ≤ n ≤ 5000) and t (t ≤ 8000).
Input is terminated by a line containing two zeroes. These two numbers are of course invalid input and should not be processed.
Output
For each line of input produce one line of output. This line contains an n-digit apparent prime number p, such that (p+2) is also an apparent prime. If here is more than one such number, anyone will do.
Although n>=3500, in the sample n=2 so that the output fits in reasonable space.
Sample Input
2 6 0 0
Sample Output
17Submit
Source: ACM ICPC Asia Regional 2011 Phuket Site