#P5615. [MtOI2019] 时间跳跃

    ID: 6332 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>动态规划 DP数学2019洛谷原创O2优化洛谷月赛

[MtOI2019] 时间跳跃

Background

Even if you know the method, you must never change the past. You must never turn a possible existence into a fixed reality. No one can predict the future, and it cannot be redone. Precisely because of this, people can accept all kinds of pain, misfortune, and sudden disasters, and keep moving forward.

Problem Description

For some reason, Rintaro owes Mayuri one banana.

To shut Mayuri up, Rintaro makes a deal with Mayuri: as long as Mayuri answers this question correctly, Mayuri can have as many bananas as she wants:


There are NN secret passages in the mechanism. The length of the ii-th secret passage is ii. The mechanism will randomly choose some secret passages from the 2n2^n possible selection plans with equal probability. If the selected secret passages can form a convex polygon, then the weight of this plan is the number of selected secret passages; otherwise, the weight is 00.

Now please compute the expected value of the weight of the selected secret passages modulo 109+710^9+7. (Two selection plans are different if and only if there exists a secret passage that is selected in one plan but not selected in the other. Note that the empty set is also a plan.)


Kurisu: Then isn’t this just...

Rintaro: Assistant, shut up!

Mayuri drew and drew on the paper, but ended up drawing nothing. So Mayuri can only ask you for help.

Input Format

The input has T+1T+1 lines in total.

The first line contains a positive integer TT, meaning there are TT queries.

The next TT lines each contain one positive integer, representing NN for this query.

Output Format

Your output should contain exactly TT lines. The ii-th line contains a non-negative integer representing the expected value for the query modulo 109+710^9+7.

5
1
2
3
4
5


0
0
0
937500007
562500005

Hint

Sample Explanation 1

It is easy to see that when nn is less than or equal to 33, it is impossible to form a valid polygon.

When n=4n=4, the following sets of chosen side lengths have non-zero weight:

{1,2,3,4}\{1,2,3,4\}, {2,3,4}\{2,3,4\}.

The answer is 716937500007 (mod1000000007)\frac{7}{16} \equiv 937500007\ (\bmod 1000000007).

When n=5n=5, the following sets of chosen side lengths have non-zero weight:

{1,2,3,4}\{1,2,3,4\}, {2,3,4}\{2,3,4\}, {1,2,3,5}\{1,2,3,5\}, {2,3,4,5}\{2,3,4,5\}

{1,3,4,5}\{1,3,4,5\}, {1,2,4,5}\{1,2,4,5\}, {2,4,5}\{2,4,5\}, {3,4,5}\{3,4,5\}, {1,2,3,4,5}\{1,2,3,4,5\}.

The answer is 3432562500005 (mod1000000007)\frac{34}{32} \equiv 562500005\ (\bmod 1000000007).

Subtasks

This problem uses bundled testdata.

For 100%100\% of the data, 1n50001\leq n\leq 5000, 1T50001\leq T \leq 5000.

There are 55 subtasks in total. The score and limits of each subtask are as follows:

Subtask 11 (2020 points): 1n101 \leq n \leq 10.

Subtask 22 (3030 points): 1n201 \leq n \leq 20.

Subtask 33 (1515 points): 1n501 \leq n \leq 50.

Subtask 44 (1515 points): 1n3001 \leq n \leq 300.

Subtask 55 (2020 points): no special restrictions.

Source

MtOI2019 Extra Round T3

Problem setter: CYJian

Checker: suwAKow

Translated by ChatGPT 5