304383: CF838C. Future Failure

Memory Limit:256 MB Time Limit:3 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Future Failure

题意翻译

### 题意 两人轮流操作一个长度为 $n$ 的由字母表中前 $k$ 个字符组成的字符串。每次将字符串重新排列或删去一个字符,并不能和之前的字符串相同。不能操作者失败。 问有多少种字符串可以使得先手必胜,对质数 $p$ 取模。 ### 数据范围 $1 \leqslant n \leqslant 250000$ , $1 \leqslant k \leqslant 26$ , $10^8 \leqslant p \leqslant 10^9+100$ ,且 $p$ 为质数。

题目描述

Alice and Bob are playing a game with a string of characters, with Alice going first. The string consists $ n $ characters, each of which is one of the first $ k $ letters of the alphabet. On a player’s turn, they can either arbitrarily permute the characters in the words, or delete exactly one character in the word (if there is at least one character). In addition, their resulting word cannot have appeared before throughout the entire game. The player unable to make a valid move loses the game. Given $ n,k,p $ , find the number of words with exactly $ n $ characters consisting of the first $ k $ letters of the alphabet such that Alice will win if both Alice and Bob play optimally. Return this number modulo the prime number $ p $ .

输入输出格式

输入格式


The first line of input will contain three integers $ n,k,p $ ( $ 1<=n<=250000 $ , $ 1<=k<=26 $ , $ 10^{8}<=p<=10^{9}+100 $ , $ p $ will be prime).

输出格式


Print a single integer, the number of winning words for Alice, modulo $ p $ .

输入输出样例

输入样例 #1

4 2 100000007

输出样例 #1

14

说明

There are 14 strings that that Alice can win with. For example, some strings are "bbaa" and "baaa". Alice will lose on strings like "aaaa" or "bbbb".

Input

题意翻译

### 题意 两人轮流操作一个长度为 $n$ 的由字母表中前 $k$ 个字符组成的字符串。每次将字符串重新排列或删去一个字符,并不能和之前的字符串相同。不能操作者失败。 问有多少种字符串可以使得先手必胜,对质数 $p$ 取模。 ### 数据范围 $1 \leqslant n \leqslant 250000$ , $1 \leqslant k \leqslant 26$ , $10^8 \leqslant p \leqslant 10^9+100$ ,且 $p$ 为质数。

加入题单

算法标签: