#P3197. [HNOI2008] 越狱
[HNOI2008] 越狱
Description
There are rooms in the prison, with one prisoner in each room. There are religions, and each prisoner believes in exactly one of them. If prisoners in adjacent rooms have the same religion, a prison break may occur. Count how many states may lead to a prison break.
Output the answer modulo .
Input Format
The input contains a single line with two integers, the number of religions and the number of rooms .
Output Format
Output a single integer on one line representing the answer.
2 3
6
Hint
Sample Input/Output 1 Explanation
| State ID | Room 1 | Room 2 | Room 3 |
|---|---|---|---|
| 1 | Religion 1 | Religion 1 | Religion 1 |
| 2 | Religion 2 | ||
| 3 | Religion 2 | ||
| 4 | Religion 2 | Religion 1 | |
| 5 | Religion 2 | Religion 2 | |
| 6 | Religion 1 | ||
Constraints
For of the testdata, it is guaranteed that , .
Translated by ChatGPT 5
京公网安备 11011102002149号