Logo
(追記) (追記ここまで)

21120번 - Beautiful Sequence Unraveling 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
7 초 512 MB777100.000%

문제

You are a happy possessor of the powerful tool called Beautiful Sequence Unraveler (BSU). This tool works with beautiful sequences. A beautiful sequence is an array $a_1, a_2, \ldots, a_n$ of $n$ integers for which the following statement holds: there are no integers $i$ such that 1ドル \le i < n$ and $\max\{a_1, \dots, a_i\} = \min\{a_{i + 1}, \dots a_n\}$.

BSU deals with beautiful sequences pretty well, but you do not know how frequently such sequences occur. So you want to calculate the number of beautiful sequences among all the arrays of length $n$ which consist of integers between 1ドル$ and $k,ドル inclusively. Since this number may be large, you are required to calculate it modulo prime number $p$.

입력

The only line contains three integers $n,ドル $k,ドル $p$ (1ドル \le n \le 400,ドル 1ドル \le k \le 10^8,ドル 998ドル,244円,353円 \le p \le 10^9 + 9$).

It is guaranteed that $p$ is prime.

출력

Print the answer to the problem modulo $p$.

제한

예제 입력 1

2 2 1000000007

예제 출력 1

2

예제 입력 2

3 4 1000000009

예제 출력 2

36

예제 입력 3

228 112263 998244353

예제 출력 3

379700769

힌트

출처

Camp > Petrozavodsk Programming Camp > Winter 2021 > Day 8: Belarusian SU Contest, Yandex Cup, Grand Prix of Belarud B번

Contest > Open Cup > 2020/2021 Season > Stage 12: Grand Prix of Belarus B번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /