#K50987. Tile Painting Ways
Tile Painting Ways
Tile Painting Ways
You are given an integer n representing the number of tiles in a row. Each tile must be painted such that no two adjacent tiles share the same color.
The painting rule is defined as follows: for any number of tiles n, if n is even and n \ge 2
, then there are exactly 2
ways to paint the tiles. Otherwise, if n is odd (or less than 2), the answer is 0
.
In mathematical notation, the answer f(n) is given by:
\[ f(n)=\begin{cases} 2, & \text{if } n \text{ is even and } n \ge 2,\\ 0, & \text{otherwise.} \end{cases} \]Your task is to implement a program that reads several test cases and outputs the corresponding results.
inputFormat
The input consists of several lines. Each line contains a single integer n indicating the number of tiles. The input terminates with a line containing the integer 0
(which should not be processed).
outputFormat
For each test case (each integer n excluding the terminating 0), output the number of painting ways as defined above on a new line.
## sample8
4
2
0
2
2
2
</p>