luogu#P3197. [HNOI2008] 越狱

    ID: 7227 Type: RemoteJudge 1000ms 125MiB Tried: 13 Accepted: 9 Difficulty: 5 Uploaded By: Tags>容斥数论数学组合数学各省省选2008湖南O2优化

[HNOI2008] 越狱

Problem Description

There are nn rooms in the prison, with one prisoner in each room. There are mm 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 100,003100{,}003.

Input Format

The input contains a single line with two integers, the number of religions mm and the number of rooms nn.

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 100%100\% of the testdata, it is guaranteed that 1m1081 \le m \le 10^8, 1n10121 \le n \le 10^{12}.

Translated by ChatGPT 5