Dynamic Programming21 sections · 916 units
Open in Course

Tri Tiling - Problem Statement

UVa 10918

Count ways to tile a 3×n3 \times n rectangle with 1×21 \times 2 dominoes. Input Format: - Multiple test cases, one per line.

Each line contains integer nn (0n300 \leq n \leq 30) - Terminates when n=1n = -1 Output: One answer per line. What to notice: - For odd nn, answer is 00 (can't tile 3×odd3 \times \text{odd}) - For even nn: f(n)=4f(n2)f(n4)f(n) = 4f(n-2) - f(n-4) - Base cases: f(0)=1f(0) = 1, f(2)=3f(2) = 3