luogu#P4869. albus就是要第一个出场
albus就是要第一个出场
Problem Description
Given a positive integer sequence of length (indices start from ), let . The power set is defined as the set consisting of all subsets of . Define a mapping , where , and for a non-empty set , .
Now Albus computes the value for every set in , sorts these values in non-decreasing order into a sequence, and denotes it as sequence (indices start from ).
Given a number, what is the index of its first occurrence in sequence ?
Input Format
The first line contains an integer , the length of sequence . The next line contains integers representing , separated by spaces. The last number is , the given number.
Output Format
Output one line with one integer: the value of the index of the first occurrence of in sequence modulo .
3
1 2 3
1
3
Hint
[Sample Explanation]
$2^S = \{\emptyset,\{1\},\{2\},\{3\},\{1,2\},\{1,3\},\{2,3\},\{1,2,3\}\}$
Therefore,
[Constraints]
All other inputs do not exceed .
Translated by ChatGPT 5