Codeforces Global Round 14
E
Phoenix and Computers
Codeforces
2200
原题
← DF →
翻译中…

There are $n$ computers in a row, all originally off, and Phoenix wants to turn all of them on. He will manually turn on computers one at a time. At any point, if computer $i-1$ and computer $i+1$ are both on, computer $i$ $(2 \le i \le n-1)$ will turn on automatically if it is not already on. Note that Phoenix cannot manually turn on a computer that already turned on automatically.

翻译中…

If we only consider the sequence of computers that Phoenix turns on manually, how many ways can he turn on all the computers? Two sequences are distinct if either the set of computers turned on manually is distinct, or the order of computers turned on manually is distinct. Since this number may be large, please print it modulo $M$.

翻译中…

Input

翻译中…

The first line contains two integers $n$ and $M$ ($3 \le n \le 400$; $10^8 \le M \le 10^9$) — the number of computers and the modulo. It is guaranteed that $M$ is prime.

翻译中…

Output

翻译中…

Print one integer — the number of ways to turn on the computers modulo $M$.

翻译中…

Note

翻译中…

In the first example, these are the $6$ orders in which Phoenix can turn on all computers:

翻译中…
  • $[1,3]$. Turn on computer $1$, then $3$. Note that computer $2$ turns on automatically after computer $3$ is turned on manually, but we only consider the sequence of computers that are turned on manually.
  • $[3,1]$. Turn on computer $3$, then $1$.
  • $[1,2,3]$. Turn on computer $1$, $2$, then $3$.
  • $[2,1,3]$
  • $[2,3,1]$
  • $[3,2,1]$
翻译中…

样例

Input #1
3 100000007
Output #1
6
InputCopy OutputCopy
Input #2
4 100000007
Output #2
20
InputCopy OutputCopy
Input #3
400 234567899
Output #3
20914007
InputCopy OutputCopy
题目信息
题号
1515E
时间限制
3 s
内存限制
256 MB
标签
组合数学
动态规划
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。