#P14709. [ICPC 2023 Tehran R] Jackson House

[ICPC 2023 Tehran R] Jackson House

题目描述

Jackson, after witnessing the advancements in the world of technology, decided to sell his small cozy house and enroll in the programming-and-algorithm micromaster. He came across an interesting algorithm that he needed to analyze and solve the problem related to it, in order to pass the exam at this stage of the course. The pseudocode of this algorithm is as follows:

$$\begin{array}{l} \textbf{input:} \text{ a permutation } \pi = \langle \pi_1, \pi_2, \ldots, \pi_n \rangle \text{ of numbers } \{1, 2, \ldots, n\} \\ \textbf{while } \pi \text{ is changing during this iteration:} \\ \quad \textbf{for } i := n \textbf{ downto } 2: \\ \quad\quad \textbf{if } \pi_i < \pi_{\lfloor i/2 \rfloor}: \\ \quad\quad\quad \text{swap}(\pi_i, \pi_{\lfloor i/2 \rfloor}) \end{array}$$

He wants to know for how many permutations π\pi of length nn from the possible n!n! ones, the final permutation will be sorted after running this algorithm.

输入格式

The first line contains an integer tt (1t1001 \leq t \leq 100), the number of test cases.

Each of the next tt lines contains an integer nin_i (2ni1092 \leq n_i \leq 10^9), representing the length of the permutation for the ithi^{th} test case.

输出格式

Output tt lines. On the ithi^{th} line, print the number of permutations of length nin_i which will be sorted after running the provided algorithm on it. Since the output could be very large, output the result modulo 109+710^9 + 7.

4
3
5
10
20
4
16
1728
23887872