Codeforces 479E. Riding in a Lift DP

Imagine that you are in a building that has exactlynfloors. You can move between the floors in a lift. Let’s number the floors from bottom to top with integers from1ton. Now you’re on the floor numbera. You are very bored, so you want to take the lift. Floor numberbhas a secret lab, the entry is forbidden. However, you already are in the mood and decide to makekconsecutive trips in the lift.

Let us suppose that at the moment you are on the floor numberx(initially, you were on floora). For another trip between floors you choose some floor with numbery(y≠x) and the lift travels to this floor. As you cannot visit floorbwith the secret lab, you decided that the distance from the current floorxto the chosenymust be strictly less than the distance from the current floorxto floorbwith the secret lab. Formally, it means that the following inequation must fulfill:|x-y|<|x-b|. After the lift successfully transports you to floory, you write down numberyin your notepad.

Your task is to find the number of distinct number sequences that you could have written in the notebook as the result ofktrips in the lift. As the sought number of trips can be rather large, find the remainder after dividing the number by1000000007(109+7).

,依赖别人的人等于折断了自己的翅膀,永远也体会不到飞翔的快乐。

Codeforces 479E. Riding in a Lift DP

相关文章:

你感兴趣的文章:

标签云: