Teemo has a formula and he want to calculate it quickly.
As the result may be very large, please output the result mod 1000000007.
Input Format
The input contains several test cases, and the first line is a positive integer T indicating the number of test cases which is up to 10^5.
For each test case, the first line contains an integer n(1<=n<=10^9).
Output Format
For each test case, output a line containing an integer that indicates the answer.
样例输入
2 2 3
样例输出
6 24
1 #include <iostream> 2 #include <cstdio> 3 #include <algorithm> 4 #include <cstdlib> 5 #include <cstring> 6 #include <string> 7 #include <deque> 8 #include <map> 9 #include <vector> 10 #include <stack> 11 using namespace std; 12 #define ll long long 13 #define N 29 14 #define M 1000000000 15 #define gep(i,a,b) for(int i=a;i<=b;i++) 16 #define gepp(i,a,b) for(int i=a;i>=b;i--) 17 #define gep1(i,a,b) for(ll i=a;i<=b;i++) 18 #define gepp1(i,a,b) for(ll i=a;i>=b;i--) 19 #define mem(a,b) memset(a,b,sizeof(a)) 20 #define ph push_back 21 #define mod 1000000007 22 ll poww(ll a,ll b){//pow会编译错误 23 ll ans=1%mod; 24 while(b){ 25 if(b&1) { 26 ans=ans*a%mod; 27 } 28 b>>=1; 29 a=a*a%mod; 30 } 31 return ans%mod; 32 } 33 int t; 34 ll n; 35 /* 36 i从1到n i*i*C(n,i)的累加和 37 38 在N个人里面选若干人,再选一个正司令、副司令 的方法数目 39 两个司令可以是同一个人 40 1 : 同一人 C(n,1)*2^(n-1)//一定至少有一个人是司令,其他的N-1个人(每人有两种可能性)可以是,也可以不是 41 2 : 两个人 A(n,2)*2^(n-2) 同理 ,2个人要考虑顺序 42 也就是 n*(n+1)*2^(n-2) 43 */ 44 45 int main() 46 { 47 scanf("%d",&t); 48 while(t--){ 49 scanf("%lld",&n); 50 if(n==1) {printf("1 ");continue;}//特判 51 ll ans=n*(n+1)%mod*poww(2,n-2)%mod; 52 printf("%lld ",ans); 53 } 54 return 0; 55 }