

Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 点
問題文
コンテストで使う 問の問題がジャッジに選ばれ、各問に配点を付ける段階になりました。
問題 の配点 は、 以上 以下の整数でなければなりません。 また、すでに問題は難易度順に並んでおり、 でなければなりません (複数問の配点が同じになるのは構いませんが)。
ICPC のファンであるあなたは、解いた問題数が多い参加者ほど上位となってほしいと考えています。 この理由から、任意の () に対して、任意の 問の配点の合計が任意の 問の配点の合計より真に小さくなるようにしたい、とあなたは考えています。
このような配点の付け方は何通りあるでしょうか?この数を与えられた素数 で割った余りを求めてください。
制約
- は素数である。
- 入力中のすべての値は整数である。
入力
入力は以下の形式で標準入力から与えられる。
出力
配点の付け方の数を で割った余りを出力せよ。
入力例 1Copy
2 998244353
出力例 1Copy
3
可能な配点の付け方は , , です。
入力例 2Copy
3 998244353
出力例 2Copy
7
可能な配点の付け方は , , , , , , です。
入力例 3Copy
6 966666661
出力例 3Copy
66
入力例 4Copy
96 925309799
出力例 4Copy
83779
Score : points
Problem Statement
problems have been chosen by the judges, now it's time to assign scores to them!
Problem must get an integer score between and , inclusive. The problems have already been sorted by difficulty: must hold. Different problems can have the same score, though.
Being an ICPC fan, you want contestants who solve more problems to be ranked higher. That's why, for any (), you want the sum of scores of any problems to be strictly less than the sum of scores of any problems.
How many ways to assign scores do you have? Find this number modulo the given prime .
Constraints
- is a prime.
- All input values are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the number of ways to assign scores to the problems, modulo .
Sample Input 1Copy
2 998244353
Sample Output 1Copy
3
The possible assignments are , , .
Sample Input 2Copy
3 998244353
Sample Output 2Copy
7
The possible assignments are , , , , , , .
Sample Input 3Copy
6 966666661
Sample Output 3Copy
66
Sample Input 4Copy
96 925309799
Sample Output 4Copy
83779