Teemo has a formula and he want to calculate it quickly.

The formula is .

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
 #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <string>
#include <deque>
#include <map>
#include <vector>
#include <stack>
using namespace std;
#define ll long long
#define N 29
#define M 1000000000
#define gep(i,a,b) for(int i=a;i<=b;i++)
#define gepp(i,a,b) for(int i=a;i>=b;i--)
#define gep1(i,a,b) for(ll i=a;i<=b;i++)
#define gepp1(i,a,b) for(ll i=a;i>=b;i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define ph push_back
#define mod 1000000007
ll poww(ll a,ll b){//pow会编译错误
ll ans=%mod;
while(b){
if(b&) {
ans=ans*a%mod;
}
b>>=;
a=a*a%mod;
}
return ans%mod;
}
int t;
ll n;
/*
i从1到n i*i*C(n,i)的累加和 在N个人里面选若干人,再选一个正司令、副司令 的方法数目
两个司令可以是同一个人
1 : 同一人 C(n,1)*2^(n-1)//一定至少有一个人是司令,其他的N-1个人(每人有两种可能性)可以是,也可以不是
2 : 两个人 A(n,2)*2^(n-2) 同理 ,2个人要考虑顺序
也就是 n*(n+1)*2^(n-2)
*/ int main()
{
scanf("%d",&t);
while(t--){
scanf("%lld",&n);
if(n==) {printf("1\n");continue;}//特判
ll ans=n*(n+)%mod*poww(,n-)%mod;
printf("%lld\n",ans);
}
return ;
}

ACM训练联盟周赛 Teemo's formula的更多相关文章

  1. 计蒜客 28449.算个欧拉函数给大家助助兴-大数的因子个数 (HDU5649.DZY Loves Sorting) ( ACM训练联盟周赛 G)

    ACM训练联盟周赛 这一场有几个数据结构的题,但是自己太菜,不会树套树,带插入的区间第K小-替罪羊套函数式线段树, 先立个flag,BZOJ3065: 带插入区间K小值 计蒜客 Zeratul与Xor ...

  2. 计蒜客 ACM训练联盟周赛 第一场 Christina式方格取数 思维

    助手Christina发明了一种方格取数的新玩法:在n*m的方格棋盘里,每个格子里写一个数.两个人轮流给格子染色,直到所有格子都染了色.在所有格子染色完后,计算双方的分数.对于任意两个相邻(即有公共边 ...

  3. 计蒜客 ACM训练联盟周赛 第一场 从零开始的神棍之路 暴力dfs

    题目描述 ggwdwsbs最近被Zeratul和Kyurem拉入了日本麻将的坑.现在,ggwdwsbs有13张牌,Kyurem又打了一张,加起来有14张牌.ggwdwsbs想拜托你帮他判断一下,这14 ...

  4. 计蒜客 ACM训练联盟周赛 第一场 Alice和Bob的Nim游戏 矩阵快速幂

    题目描述 众所周知,Alice和Bob非常喜欢博弈,而且Alice永远是先手,Bob永远是后手. Alice和Bob面前有3堆石子,Alice和Bob每次轮流拿某堆石子中的若干个石子(不可以是0个), ...

  5. ACM训练联盟周赛(第三场)

    A.Teemo's bad day Today is a bad day. Teemo is scolded badly by his teacher because he didn't do his ...

  6. ACM训练联盟周赛 A. Teemo's bad day

    65536K   Today is a bad day. Teemo is scolded badly by his teacher because he didn't do his homework ...

  7. ACM训练联盟周赛 K. Teemo's reunited

    Teemo likes to drink raspberry juice.  He even spent some of his spare time tomake the raspberry jui ...

  8. ACM训练联盟周赛 G. Teemo's convex polygon

    65536K   Teemo is very interested in convex polygon. There is a convex n-sides polygon, and Teemo co ...

  9. 计蒜客 28437.Big brother said the calculation-线段树+二分-当前第k个位置的数 ( ACM训练联盟周赛 M)

    M. Big brother said the calculation 通过线段树维护. 这个题和杭电的一道题几乎就是一样的题目.HDU5649.DZY Loves Sorting 题意就是一个n的排 ...

随机推荐

  1. Php对象及对象特性篇

    前言 以前写C++最多,大二课上学过Java.现在也差不多还给老师了.现在决定针对php重新梳理一遍,夯实基础,设计模式学起来应该会更加得心应手吧. 介绍 对象作为数据和功能代码的集合,是程序开发和代 ...

  2. Codeforces Round #402 (Div. 2) A

    Description In Berland each high school student is characterized by academic performance — integer v ...

  3. 530 Minimum Absolute Difference in BST 二叉搜索树的最小绝对差

    给定一个所有节点为非负值的二叉搜索树,求树中任意两节点的差的绝对值的最小值.示例 :输入:   1    \     3    /   2输出:1解释:最小绝对差为1,其中 2 和 1 的差的绝对值为 ...

  4. python学习之邮件

    分类smtp邮件 html邮件,带附件的邮件. 一 STTP邮件:设置SMTP代理机构,发送人的邮箱和密码,收件人的邮箱地址(email模块):接收端,发送(smtplib模块).SMTP(smtp_ ...

  5. simhash与重复信息识别

    在工作学习中,我往往感叹数学奇迹般的解决一些貌似不可能完成的任务,并且十分希望将这种喜悦分享给大家,就好比说:“老婆,出来看上帝”…… 随着信息爆炸时代的来临,互联网上充斥着着大量的近重复信息,有效地 ...

  6. nodejs json

    var express = require('express');var router = express.Router(); /* GET home page. */ router.get('/', ...

  7. Genymotion的安装与设置

    Genymotion是一款非常好用的虚拟机,利用它可以在window.Liunx或MAC系统上实现Android的模似器.对于开发人员来说,有了Android模似器,就可以在电脑上实时调试安卓app, ...

  8. shiro : java.lang.IllegalArgumentException: Odd number of characters.

    shiro使用的时候: java.lang.IllegalArgumentException: Odd number of characters.    at org.apache.shiro.cod ...

  9. Servlet Context

    Servlet Context Container Provider 负责提供ServletContext的实现. A ServletContext is rooted at a known path ...

  10. mysql 存在更新,不存在插入

    String sql = "insert into wb_result " + "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,? ...