The input consists of one or more matrices. Each matrix is represented
by a line containing the number of rows m and columns n
in the matrix, followed by m lines each containing n
population values separated by spaces. A zero value for m or n
signals the end of input. A matrix will have at most 16 elements.
For each nonempty matrix, output a line of the form
Matrix #i: s solution(s),
where i is 1 for the first matrix, 2 for the second, etc, and
s is the number of ways that the matrix can be subdivided.
If s > 0, output each solution on a line by itself exactly as shown in
the example below; list the populations in one region surrounded by parentheses, then the
populations in the other region surrounded by parentheses.
It doesn't matter in what order the regions or populations are listed.
Input must be read from the file "prob2.in", and output must be
written to the file "prob2.out". All output to the screen will be
ignored.
<BOF> 4 4 50 85 9 33 301 46 40 19 105 29 11 12 20 13 23 16 2 3 3 5 12 4 1 30 3 4 16 11 91 14 77 55 82 23 31 10 18 72 0 3 <EOF>
Matrix #1: 1 solution(s) (301 105) (50 85 9 33 46 40 19 29 11 12 20 13 23 16) Matrix #2: 0 solution(s) Matrix #3: 2 solution(s) (16 11 91 77 55) (14 82 23 31 10 18 72) (82 23 18 72 55) (16 11 91 14 77 31 10)
Dr. Eric Shade