Jackson House

시간 제한1초메모리 제한2048 MB

요약
주어진 힙 기반 교환 알고리즘을 적용했을 때 정렬된 순열이 되는 {1..n}의 순열 개수를 n마다 센다.
난이도

어려움10점 중 8점

유형
조합론, 수학, 트리
정답자
아직 제출이 없습니다

문제

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:

input: a permutation $π = <π_1, π_2, \dots , π_n>$ of numbers $\{1, 2, \dots , n\}$
while $π$ is changing during this iteration:
    for $i := n$ downto $2$:
        if $π_i < π_{\lfloor i/2 \rfloor}$:
            swap($π_i$, $π_{\lfloor i/2 \rfloor}$)

He wants to know for how many permutations ππ 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 (1≤t≤1001 \le t \le 100), the number of test cases.

Each of the next tt lines contains an integer n_in\_i (2≤n_i≤1092 \le n\_i \le 10^9), representing the length of the permutation for the iith test case.

출력

Output tt lines. On the iith line, print the number of permutations of length n_in\_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.

예제1

  1. 예제 1

    입력
    4
    3
    5
    10
    20
    
    예상 출력
    4
    16
    1728
    23887872