Problem 364
Comfortable distance
There are N seats in a row. N people come after each other to fill the seats according to the following rules:
- If there is any seat whose adjacent seat(s) are not occupied take such a seat.
- If there is no such seat and there is any seat for which only one adjacent seat is occupied take such a seat.
- Otherwise take one of the remaining available seats.
Let T(N) be the number of possibilities that N seats are occupied by N people with the given rules. The following figure shows T(4)=8.
We can verify that T(10) = 61632 and T(1 000) mod 100 000 007 = 47255094.
Find T(1 000 000) mod 100 000 007.
舒适距离
有N个座位排成一行。N个人陆续前来,根据以下规则选择座位:
- 如果存在空座位两侧都没有人,则选择这样的座位。
- 如果没有这样的座位,但存在空座位只有一侧有人,则选择这样的座位。
- 否则,选择任意一张剩下的空座位。
记T(N)为在上述规则下N个人坐N个座位的所有可能性。下图说明T(4)=8。
我们可以验证T(10) = 61632以及T(1 000) mod 100 000 007 = 47255094。
求T(1 000 000) mod 100 000 007。