#P1057. [NOIP 2008 普及组] 传球游戏

    ID: 57 远端评测题 1000ms 125MiB 尝试: 1 已通过: 1 难度: 5 上传者: 标签>模拟动态规划,dp递推2008NOIp 普及组

[NOIP 2008 普及组] 传球游戏

Description

During PE class, Xiaoman’s teacher often plays games with the students. This time, the teacher is leading a passing game.

The rules are as follows: nn students stand in a circle. One student holds a ball at the start. When the teacher blows the whistle, the passing begins. Each student can pass the ball to either of their two neighbors (left or right, chosen arbitrarily). When the teacher blows the whistle again, the passing stops. At that moment, the student holding the ball, who has not passed it on, is the loser and must perform a show for everyone.

Xiaoman提出了一个有趣的问题: In how many different ways can the ball, starting from Xiaoman, return to Xiaoman after mm passes? Two passing methods are considered different if and only if the sequences of students who receive the ball, in the order they receive it, are different. For example, with three students numbered 11, 22, and 33, and assuming Xiaoman is number 11, there are 22 ways for the ball to return to Xiaoman after 33 passes: 12311 \rightarrow 2 \rightarrow 3 \rightarrow 1 and 13211 \rightarrow 3 \rightarrow 2 \rightarrow 1.

Input Format

One line with two space-separated integers n,m(3n30,1m30)n,m(3 \le n \le 30,1 \le m \le 30).

Output Format

11 integer, representing the number of valid methods.

3 3
2

Hint

Constraints and Conventions

  • For 40%40\% of the testdata, it holds that: 3n30,1m203 \le n \le 30,1 \le m \le 20.
  • For 100%100\% of the testdata, it holds that: 3n30,1m303 \le n \le 30,1 \le m \le 30.

Third problem of the 2008 Junior.

Translated by ChatGPT 5