AT_arc221_b.Two-Powered Sum
省选/NOI-
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given a positive integer N and a prime P.
There is a length-N sequence A=(A1,A2,…,AN) where all elements are 0.
You can repeat the following operation any number of times, possibly zero:
- Choose a non-empty subset S of {1,2,…,N}. Let x=i∈S∑2i−1. For each i∈S, replace Ai with x.
Find the number, modulo P, of possible sequences A after repeating the operations.
给你一个正整数 N 和一个质数 P。
有一个长度为 N 的序列 A=(A1,A2,…,AN),其中所有元素初始均为 0。
你可以任意次(包括零次)执行以下操作:
- 选择集合 {1,2,…,N} 的一个非空子集 S。令 x=i∈S∑2i−1。对每个 i∈S,将 Ai 替换为 x。
求经过若干次操作后,可能得到的不同序列 A 的个数(对 P 取模)。
输入格式
The input is given from Standard Input in the following format:
N P
输入从标准输入中以如下格式给出:
N P
输出格式
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 A are (0),(1), giving two possibilities.
Sample 2 Explanation:
The possible sequences A are (0,0),(0,2),(1,0),(1,2),(1,3),(3,2),(3,3), giving seven possibilities.
Constraints
- 1≤N≤700
- P is a prime satisfying 108<P<109.
- All input values are integers.
样例 1 解释:
可能的序列 A 为 (0)、(1),共两种可能。
样例 2 解释:
可能的序列 A 为 (0,0)、(0,2)、(1,0)、(1,2)、(1,3)、(3,2)、(3,3),共七种可能。
约束条件
- 1≤N≤700
- P 是一个满足 108<P<109 的质数。
- 所有输入值均为整数。
输入解题思路,AI测评打分。不知道怎么写?