CF1605F.PalindORme

省选/NOI-

通过率:0%

时间限制:4.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

An integer array aa of length nn is said to be a PalindORme if (a1a_{1} ∣| $a_{2} $ ∣| $ \ldots $ ∣| $ a_{i}) = (a_{{n - i + 1}} $ ∣| $ \ldots $ ∣| $ a_{{n - 1}} $ ∣| $ a_{n}) $ for all $ 1 \leq i \leq n$, where ∣| denotes the bitwise OR operation.

An integer array aa of length nn is considered to be good if its elements can be rearranged to form a PalindORme. Formally, array aa is good if there exists a permutation p1,p2,…pnp_1, p_2, \ldots p_n (an array where each integer from 11 to nn appears exactly once) for which ap1,ap2,…apna_{p_1}, a_{p_2}, \ldots a_{p_n} is a PalindORme.

Find the number of good arrays of length nn, consisting only of integers in the range [0,2k−1][0, 2^{k} - 1], and print it modulo some prime mm.

Two arrays a1,a2,…,ana_1, a_2, \ldots, a_n and b1,b2,…,bnb_1, b_2, \ldots, b_n are considered to be different if there exists any ii (1≤i≤n)(1 \leq i \leq n) such that ai≠bia_i \ne b_i.

长度为 nn 的整数数组 aa 被称为 PalindORme(“或回文”),当且仅当对所有 1≤i≤n1 \leq i \leq n,均满足

(a1∣a2∣…∣ai)=(an−i+1∣…∣an−1∣an),(a_{1} \mid a_{2} \mid \ldots \mid a_{i}) = (a_{{n - i + 1}} \mid \ldots \mid a_{{n - 1}} \mid a_{n}),

其中 ∣\mid 表示按位或运算。

长度为 nn 的整数数组 aa 被称为 好数组(good array),如果其元素可以重排后构成一个 PalindORme。形式化地说,数组 aa 是好数组,当且仅当存在一个排列 p1,p2,…,pnp_1, p_2, \ldots, p_n(即 11 到 nn 的每个整数在该数组中恰好出现一次),使得重排后的数组 ap1,ap2,…,apna_{p_1}, a_{p_2}, \ldots, a_{p_n} 是一个 PalindORme。

求长度为 nn、且每个元素均属于区间 [0,2k−1][0, 2^{k} - 1] 的好数组的个数,并将结果对某个质数 mm 取模后输出。

若存在某个下标 ii(1≤i≤n1 \leq i \leq n)使得 ai≠bia_i \ne b_i,则称两个数组 a1,a2,…,ana_1, a_2, \ldots, a_n 与 b1,b2,…,bnb_1, b_2, \ldots, b_n 不同。

输入格式

The first and only line of the input contains three integers nn, kk and mm (1≤n,k≤801 \leq n,k \leq 80, 108<m<10910^8 \lt m \lt 10^9). It is guaranteed that mm is prime.

输入仅有一行,包含三个整数 nn、kk 和 mm(1≤n,k≤801 \leq n,k \leq 80,108<m<10910^8 \lt m \lt 10^9)。保证 mm 是质数。

输出格式

Print a single integer — the number of good arrays modulo mm.

输出一个整数——好数组的个数对 mm 取模的结果。

输入输出样例

  • 输入#1

    1 1 998244353

    输出#1

    2
  • 输入#2

    3 2 999999733

    输出#2

    40
  • 输入#3

    7 3 796735397

    输出#3

    1871528
  • 输入#4

    2 46 606559127

    输出#4

    177013

说明/提示

In the first sample, both the possible arrays [0][0] and [1][1] are good.

In the second sample, some examples of good arrays are:

  • [2,1,2][2, 1, 2] because it is already PalindORme.
  • [1,1,0][1, 1, 0] because it can rearranged to [1,0,1][1, 0, 1] which is PalindORme

Note that [1,1,0][1, 1, 0], [1,0,1][1, 0, 1] and [0,1,1][0, 1, 1] are all good arrays and are considered to be different according to the definition in the statement.

In the third sample, an example of a good array is [1,0,1,4,2,5,4][1, 0, 1, 4, 2, 5, 4]. It can be rearranged to an array b=[1,5,0,2,4,4,1]b = [1, 5, 0, 2, 4, 4, 1] which is a PalindORme because:

  • OR(1,1)\mathrm{OR}(1, 1) = OR(7,7)\mathrm{OR}(7, 7) = 11
  • OR(1,2)\mathrm{OR}(1, 2) = OR(6,7)\mathrm{OR}(6, 7) = 55
  • OR(1,3)\mathrm{OR}(1, 3) = OR(5,7)\mathrm{OR}(5, 7) = 55
  • OR(1,4)\mathrm{OR}(1, 4) = OR(4,7)\mathrm{OR}(4, 7) = 77
  • OR(1,5)\mathrm{OR}(1, 5) = OR(3,7)\mathrm{OR}(3, 7) = 77
  • OR(1,6)\mathrm{OR}(1, 6) = OR(2,7)\mathrm{OR}(2, 7) = 77
  • OR(1,7)\mathrm{OR}(1, 7) = OR(1,7)\mathrm{OR}(1, 7) = 77

Here OR(l,r)\mathrm{OR}(l, r) denotes blb_{l} ∣| $b_{l+1} $ ∣| $ \ldots $ ∣| $ b_{r}$

在第一个样例中,两个可能的数组 [0][0] 和 [1][1] 均为好数组。

在第二个样例中,一些好数组的例如下:

  • [2,1,2][2, 1, 2],因为它本身已是 PalindORme;
  • [1,1,0][1, 1, 0],因为它可重排为 [1,0,1][1, 0, 1],而后者是 PalindORme。

注意:根据题目陈述中的定义,[1,1,0][1, 1, 0]、[1,0,1][1, 0, 1] 和 [0,1,1][0, 1, 1] 均为好数组,且被视为互不相同的数组。

在第三个样例中,一个好数组的例子是 [1,0,1,4,2,5,4][1, 0, 1, 4, 2, 5, 4]。它可以被重排为数组 b=[1,5,0,2,4,4,1]b = [1, 5, 0, 2, 4, 4, 1],该数组是一个 PalindORme,因为:

  • OR(1,1)\mathrm{OR}(1, 1) = OR(7,7)\mathrm{OR}(7, 7) = 11
  • OR(1,2)\mathrm{OR}(1, 2) = OR(6,7)\mathrm{OR}(6, 7) = 55
  • OR(1,3)\mathrm{OR}(1, 3) = OR(5,7)\mathrm{OR}(5, 7) = 55
  • OR(1,4)\mathrm{OR}(1, 4) = OR(4,7)\mathrm{OR}(4, 7) = 77
  • OR(1,5)\mathrm{OR}(1, 5) = OR(3,7)\mathrm{OR}(3, 7) = 77
  • OR(1,6)\mathrm{OR}(1, 6) = OR(2,7)\mathrm{OR}(2, 7) = 77
  • OR(1,7)\mathrm{OR}(1, 7) = OR(1,7)\mathrm{OR}(1, 7) = 77

此处 OR(l,r)\mathrm{OR}(l, r) 表示 blb_{l} ∣| $b_{l+1} $ ∣| $ \ldots $ ∣| $ b_{r}$。

输入解题思路,AI测评打分。不知道怎么写?

首页