Problem 726
Falling bottles
Consider a stack of bottles of wine. There are
The collapsing process happens every time a bottle is taken. A space is created in the stack and that space is filled according to the following recursive steps:
- No bottle touching from above: nothing happens. For example, taking
. - One bottle touching from above: that will drop down to fill the space creating another space. For example, taking
. - Two bottles touching from above: one will drop down to fill the space creating another space. For example, taking
.
This process happens recursively; for example, taking bottle
Define
You are given
Also define
Find
掉落的酒瓶
一堆酒瓶被摆成
每次从这堆酒瓶中拿走一瓶酒,就会触发一连串掉落过程。被拿走的酒瓶所留下的空位会根据以下规则填满:
- 空位上方没有酒瓶,则什么都不会发生,比如在上图中拿走
。 - 空位上方只有一个酒瓶,则该酒瓶掉落填补空位,并在原位置留下一个新的空位,比如在上图中拿走
。 - 空位上方有两个酒瓶,则其中一个酒瓶掉落填补空位,并在原位置留下一个新的空位,比如在上图中拿走
。
如果有新空位出现,则上述过程会持续进行;例如,在上图中拿走
记
已知
再记
求
Be the first person to leave a comment!