AT_arc221_b.Two-Powered Sum

省选/NOI-

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

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

题目描述

You are given a positive integer NN and a prime PP.

There is a length-NN sequence A=(A1,A2,…,AN)A=(A_1,A_2,\ldots,A_N) where all elements are 00.

You can repeat the following operation any number of times, possibly zero:

  • Choose a non-empty subset SS of {1,2,…,N}\lbrace 1,2,\ldots,N\rbrace. Let x=∑i∈S2i−1\displaystyle x=\sum_{i\in S}2^{i-1}. For each i∈Si\in S, replace AiA_i with xx.

Find the number, modulo PP, of possible sequences AA after repeating the operations.

给你一个正整数 NN 和一个质数 PP。

有一个长度为 NN 的序列 A=(A1,A2,…,AN)A=(A_1,A_2,\ldots,A_N),其中所有元素初始均为 00。

你可以任意次(包括零次)执行以下操作:

  • 选择集合 {1,2,…,N}\lbrace 1,2,\ldots,N\rbrace 的一个非空子集 SS。令 x=∑i∈S2i−1\displaystyle x=\sum_{i\in S}2^{i-1}。对每个 i∈Si\in S,将 AiA_i 替换为 xx。

求经过若干次操作后,可能得到的不同序列 AA 的个数(对 PP 取模)。

输入格式

The input is given from Standard Input in the following format:

NN PP

输入从标准输入中以如下格式给出:

NN PP

输出格式

Output the answer.

输出答案。

输入输出样例

  • 输入#1

    1 998244353

    输出#1

    2
  • 输入#2

    2 998244353

    输出#2

    7
  • 输入#3

    3 998244353

    输出#3

    57
  • 输入#4

    4 998244353

    输出#4

    1208
  • 输入#5

    77 777777773

    输出#5

    381787647

说明/提示

Sample 1 Explanation:
The possible sequences AA are (0),(1)(0),(1), giving two possibilities.

Sample 2 Explanation:
The possible sequences AA are (0,0),(0,2),(1,0),(1,2),(1,3),(3,2),(3,3)(0,0),(0,2),(1,0),(1,2),(1,3),(3,2),(3,3), giving seven possibilities.

Constraints

  • 1≤N≤7001\leq N\leq 700
  • PP is a prime satisfying 108<P<10910^8\lt P\lt 10^9.
  • All input values are integers.

样例 1 解释:
可能的序列 AA 为 (0)(0)、(1)(1),共两种可能。

样例 2 解释:
可能的序列 AA 为 (0,0)(0,0)、(0,2)(0,2)、(1,0)(1,0)、(1,2)(1,2)、(1,3)(1,3)、(3,2)(3,2)、(3,3)(3,3),共七种可能。

约束条件

  • 1≤N≤7001\leq N\leq 700
  • PP 是一个满足 108<P<10910^8\lt P\lt 10^9 的质数。
  • 所有输入值均为整数。

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

首页