#P2606. Magic Permutations
Magic Permutations
Magic Permutations
A permutation \(p_1, p_2, ..., p_n\) of \(1 \sim n\) is defined as Magic if and only if
\[ \forall i \in [2, n], \quad p_i > p_{\lfloor i/2 \rfloor} \]
This property is exactly the heap condition on a binary heap when the permutation is interpreted as the level order traversal of a complete binary tree (with 1-indexing).
Calculate the number of Magic permutations among all \(1 \sim n\) permutations. As the answer can be very large, output it modulo \(m\).
inputFormat
The input consists of a single line containing two integers \(n\) and \(m\), where \(n\) denotes the size of the permutation and \(m\) is the modulus.
outputFormat
Output a single integer, the number of Magic permutations modulo \(m\).
sample
1 10
1