#P1057. [NOIP 2008 普及组] 传球游戏
[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: 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 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 , , and , and assuming Xiaoman is number , there are ways for the ball to return to Xiaoman after passes: and .
Input Format
One line with two space-separated integers .
Output Format
integer, representing the number of valid methods.
3 3
2
Hint
Constraints and Conventions
- For of the testdata, it holds that: .
- For of the testdata, it holds that: .
Third problem of the 2008 Junior.
Translated by ChatGPT 5
京公网安备 11011102002149号