#Q198. 「一本通 6.1 练习 3」越狱
「一本通 6.1 练习 3」越狱
Description
Original Source: HNOI 2008
A prison has a sequence of rooms numbered consecutively from to , each housing one prisoner. There are different religions, and each prisoner may follow one of them. If two adjacent prisoners share the same religion, an escape attempt may occur. Calculate the number of possible states where an escape could happen.
Input Format
Input two integers, and .
Output Format
The number of possible escape states, modulo .
Sample 1
All possible states are: $\{0,0,0\},\{0,0,1\},\{0,1,1\},\{1,0,0\},\{1,1,0\},\{1,1,1\}$.
2 3
6
Constraints and Hints
For all test cases, and .