CCC '09 S2 - Lights Going On and Off
Canadian Computing Competition: 2019 Stage 1, Senior #2
For various given positive integers \(N > 3\) , find two primes, \(A\) and \(B\) such that \(N\) is the average (mean) of \(A\) and \(B\) . That is, \(N\) should be equal to \(\dfrac{A + B}{2}\) .
Recall that a prime number2 3 4 Row \(k+1\) on on off off Row \(k\) before button pushed on off on off Row \(k\) after button pushed off on on off
You are told which lights are initially on and which are initially off. You must calculate how many different light patterns are possible for the bottom row by any sequence of button pushes. Each button may only be pressed once, but in any order.
Input Specification
The first line of input will contain the integer \(R\) , the number of rows. The second line of input will contain the integer \(L\) , the number of lights per row. The next \(R\) lines of input will contain \(L\) integers, where the integer will either be \(0\) (to indicate "off") or \(1\) (to indicate "on"). Pairs of consecutive integers will be separated by one space character. These \(R\) lines will be given in topdown order: that is, the third line of input will be the description of row \(R\) , the fourth line will be \(R - 1\) , and so on, until the last line describes the bottom row.
Output Specification
Output the number of possible light patterns of the bottom row.
Sample Input
4
3
0 0 1
0 1 1
1 0 1
0 0 1Sample Output
4
Comments