UVa 406 - Prime Cuts

Summary
Given 2 numbers n and c output a list of primes less than n which contains c*2 primes from the center of the list for even number of elements. output (c*2)-1 primes from the center of the list if there are odd number of elements.

Explanation

 * Generate all the primes from 2 to 1000. For this problem, 1 is a prime number.
 * From this figure keep track of the middle of the list and figure out if there are an odd number of elements or not.
 * From this you can basically fudge your solution to work.

Gotchas

 * A presentation error of omitting blank lines between outputs may appear as a wrong answer.

Input
21 2 18 2 18 18 100 7

Output
21 2: 5 7 11

18 2: 3 5 7 11

18 18: 1 2 3 5 7 11 13 17

100 7: 13 17 19 23 29 31 37 41 43 47 53 59 61 67