Problem list
Log in
#icpc00116 · ICPC SWERC 2020

Mentors

Platinum II 3.0 s 2048 MB

3

The Happy Tree Friends have gathered for their annual meeting, in which they take their most important decisions for the year to come. This year, they will set up a mentoring program to help each other take better care of their loved ones. This programme follows a tree-like hierarchical structure as follows.

The $N$ members of the programme are ranked from $1$ to $N$ (each rank is assigned once), by increasing seniority. For the mentorship programme to be efficient, a person ranked $A$ can mentor a person ranked $B$ only if $A > B$. The most senior Happy Tree Friend can have no mentor, but everybody else has a unique mentor. Conversely, everybody is allowed to mentor from zero to two people.

However, Mr. Pickles, who was assigned the rank $R$, plans to take a sabbatical this year. Thus, he will not be able to mentor anybody, and the Happy Tree Friends should choose their hierarchical structure among those trees in which the node labelled $R$ is a leaf.

Aiming to help his friends to choose such a tree, Mr. Pickles decides to first count how many trees would match his constraint. Unfortunately, he stopped school early, and thus did not learn how to manipulate integers of arbitrary size. Instead, he counts modulo $M$, where $M$ is a fixed positive integer: this is already enough for most purposes in life.

What is the number $L$ that Mr. Pickles will obtain after counting all suitable trees?

Input

The input consists of a single line, with three space-separated integers: $R$, $N$, $M$, in that order.

Output

The output should contain a single line with the single integer $L$, which is the number of tree-like hierarchical structures that would match Mr. Pickles' constraints, counted modulo $M$.

Example 1

Input
2 4 2
Output
1

Example 2

Input
2 4 3
Output
0
Source
ICPC SWERC 2020
Appears in
Not part of a ladder, contest or set yet.
Accepted 0 Submissions 0 Acceptance 0% Solvers 0

Discussion

Threads about this problem. Spoilers are collapsed; wrap hints in ||double bars||.

No discussion yet. Start a thread if something here needs explaining.

Recent submissions Open with filters
Code