(Asked to refine the solution to be more efficient)
------------------------------------------------------------------------------------------------------
At first it seems like a dynamic programming
type of problem but looking more closely it reduces to the simple problem of finding the nth Fibonacci number. Denote by f(n) the number of possibilities to tile a 2xn board.
Consider tiling a 2xn board for some n>2. Let us sort all the possibilities according to the last 2 columns. There are f(n-1) possibilities where the last column includes
a single tile and there are f(n-2) possibilities where the last 2 columns include 2 horizontally placed tiles. This covers all possibilities and hence: f(n) = f(n-1) + f(n-2) which is exactly the nth Fibonacci number.
AND there is way to get f(n) in log(n) time.
2xN板砖填充问题

本文探讨了如何计算使用2x1板砖完全填充2xN大小的板砖的不同方式的数量。通过将问题简化为寻找第N个斐波那契数的方法,提供了一个高效的解决方案,并进一步介绍了如何在O(log N)时间内找到该数值。
1641

被折叠的 条评论
为什么被折叠?



