In how many ways can you tile a 3xn rectangle with 2x1 dominoes?

时光怂恿深爱的人放手 提交于 2019-12-07 02:08:47

问题


Everyday I struggle with algorithm questions and try to ask here which I can't answer. Excuse me, if I cause any headache. Anyway,

Here is the problem from the University of Waterloo ACM Programming Contest.

In how many ways can you tile a 3xn rectangle with 2x1 dominoes?

Nirvana : smells like recursion spirit


回答1:


You can solve this by using dynamic programming. Check this for a possible solution.




回答2:


Just an explicit solution to the equations given implicitly in taskinoor's answer:

Or

f[n]=((1 + (-1)^n)*((2 - Sqrt[3])^(n/2)*(-1 + Sqrt[3]) + 
     (1 + Sqrt[3])* (2 + Sqrt[3])^(n/2)))/(4*Sqrt[3]) 

if anyone cares.

Let's show 10 values (for odd n there are no solutions) {n,f[n]}:

{6, 41.},   
{12, 2131.},   
{18, 110771.},   
{24, 5.75796*10^6},   
{30, 2.99303*10^8},   
{36, 1.5558*10^10}, 
{42, 8.08717*10^11},  
{48, 4.20377*10^13}, 
{54, 2.18515*10^15}, 
{60, 1.13586*10^17}



回答3:


Just a note on how to get the explicit solution formula, the trick is to write it down recurrence as matrix multiplication, and then use the eigenvalue formula for nth power of a matrix. For the recursion above, the equation is

(not available)

You can see the four eigenvalues show up in the belisarius' explicit formula



来源:https://stackoverflow.com/questions/4803805/in-how-many-ways-can-you-tile-a-3xn-rectangle-with-2x1-dominoes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!