Submit | All submissions | Best solutions | Back to list |
GRIMM - A Terribly Grimm Problem |
Grimm's conjecture states that to each element of a set of consecutive composite numbers one can assign a distinct prime that divides it.
For example, for the range 242 to 250, one can assign distinct primes as follows:
Given the lower and upper bounds of a sequence of composite numbers, find a distinct prime for each. If there is more than one such assignment, output the one with the smallest first prime. If there is still more than one, output the one with the smallest second prime, and so on.
Input
There will be several test cases in the input. Each test case will consist of a single line with two integers, lo and hi (4 ≤ lo < hi ≤ 1010), separated by a single space. It is guaranteed that all the numbers in the range from lo to hi inclusive are composite. The input will end with a line with two 0s.
Output
For each test case, output the set of unique primes, in order, all on the same line, separated by single spaces. Output no extra spaces, and do not separate answers with blank lines.
Example Input
242 250 8 10 0 0
Example Output
2 3 61 7 41 13 31 83 5 2 3 5
Added by: | Joshua Kirstein |
Date: | 2015-10-20 |
Time limit: | 1s-8s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 GOSU JS-MONKEY |
Resource: | ACM SER2012 |