Find summation

3

5 votes
Combinatorics, Inclusion-exclusion, C++, Math
Problem

You are given an integer n. Determine the value of the following expression:

ns=0nr=s(nr)(rs)s2

Here, (nk) denotes the number of ways to choose k objects from a set of n objects.

Since the value of the expression can be large enough, output it modulo 109+7.

Input format

  • The first line contains a single integer T denoting the number of test cases.
  • Each of the next T lines contains a single integer n.

Output format

The output should contain T lines each containing the value of the expression for the respective integer n.

Constraints

1T1061n1015

 

Time Limit: 5
Memory Limit: 256
Source Limit:
Explanation

2s=02r=0(2r)(rs)s2=(21)(11)12+(22)(21)12+(22)(22)22=8

Editor Image

?