|---|---|---|---|---| | 1 | 1 | 3 | 5 | 1 | |---|---|---|---|---| | 3 | 3 | 2 | 0 | 3 | |---|---|---|---|---| | 3 | 0 | 3 | 2 | 3 | |---|---|---|---|---| | 1 | 4 | 0 | 3 | 3 | |---|---|---|---|---| | 3 | 3 | 3 | 1 | 1 | |---|---|---|---|---| (Figure 1)

- The prime numbers must have the same digit sum (11 in the example).
- The digit in the top left-hand corner of the square is pre-determined (1 in the example).
- A prime number may be used more than once in the same square.
- If there are several solutions, all must be presented.
- A five digit prime number cannot begin with zeros, ie 00003 is NOT a five digit prime number.

Your program is to read from standard input. First the digit sum of prime numbers and then the digit in the top left-hand corner of the square. The file contains two lines. There will always be a solution to the given test data.

Your program is to write to standard output. Output five lines for each solution found, where each line in turn consists of a five digit prime number. The solutions are sorted by the prime in the first row, then by the prime in the second row,etc. Output a blank line after each solution.

提交代码