ACM训练联盟周赛 Teemo's formula
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的更多相关文章
- 计蒜客 28449.算个欧拉函数给大家助助兴-大数的因子个数 (HDU5649.DZY Loves Sorting) ( ACM训练联盟周赛 G)
ACM训练联盟周赛 这一场有几个数据结构的题,但是自己太菜,不会树套树,带插入的区间第K小-替罪羊套函数式线段树, 先立个flag,BZOJ3065: 带插入区间K小值 计蒜客 Zeratul与Xor ...
- 计蒜客 ACM训练联盟周赛 第一场 Christina式方格取数 思维
助手Christina发明了一种方格取数的新玩法:在n*m的方格棋盘里,每个格子里写一个数.两个人轮流给格子染色,直到所有格子都染了色.在所有格子染色完后,计算双方的分数.对于任意两个相邻(即有公共边 ...
- 计蒜客 ACM训练联盟周赛 第一场 从零开始的神棍之路 暴力dfs
题目描述 ggwdwsbs最近被Zeratul和Kyurem拉入了日本麻将的坑.现在,ggwdwsbs有13张牌,Kyurem又打了一张,加起来有14张牌.ggwdwsbs想拜托你帮他判断一下,这14 ...
- 计蒜客 ACM训练联盟周赛 第一场 Alice和Bob的Nim游戏 矩阵快速幂
题目描述 众所周知,Alice和Bob非常喜欢博弈,而且Alice永远是先手,Bob永远是后手. Alice和Bob面前有3堆石子,Alice和Bob每次轮流拿某堆石子中的若干个石子(不可以是0个), ...
- ACM训练联盟周赛(第三场)
A.Teemo's bad day Today is a bad day. Teemo is scolded badly by his teacher because he didn't do his ...
- 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 ...
- ACM训练联盟周赛 K. Teemo's reunited
Teemo likes to drink raspberry juice. He even spent some of his spare time tomake the raspberry jui ...
- ACM训练联盟周赛 G. Teemo's convex polygon
65536K Teemo is very interested in convex polygon. There is a convex n-sides polygon, and Teemo co ...
- 计蒜客 28437.Big brother said the calculation-线段树+二分-当前第k个位置的数 ( ACM训练联盟周赛 M)
M. Big brother said the calculation 通过线段树维护. 这个题和杭电的一道题几乎就是一样的题目.HDU5649.DZY Loves Sorting 题意就是一个n的排 ...
随机推荐
- 2017"百度之星"程序设计大赛 - 初赛(A)今夕何夕
Problem Description 今天是2017年8月6日,农历闰六月十五. 小度独自凭栏,望着一轮圆月,发出了“今夕何夕,见此良人”的寂寞感慨. 为了排遣郁结,它决定思考一个数学问题:接下来最 ...
- C. Functions again DP + 分类讨论
http://codeforces.com/contest/789/problem/C 首先按题目要求处理出dis数组. 那么对于任意一个区间,[L, R],是dis[L] - dis[L + 1] ...
- Linux 安装reids
1.下载: wget http://download.redis.io/releases/redis-3.0.0.tar.gz 2.解压: .tar.gz 3.安装: cd /redis- make ...
- 我的NopCommerce之旅(2): 系统环境及技术分析
一.系统环境 IIS7.0 or above ASP.NET 4.5(MVC 5.0) .NET Framework 4.5.1 or above VS 2012 or above 二.架构设计 Pl ...
- asp。Net 页面传值
00.引言 Web页面是无状态的, 服务器对每一次请求都认为来自不同用户,因此,变量的状态在连续对同一页面的多次请求之间或在页面跳转时不会被保留.在用ASP.NET 设计开发一个Web系统时, 遇到一 ...
- 关于如何用jq定位到某个元素的索引
在点击事件触发时候,通常如果有同样的className的列表我们都需获取它的索引来知道到底点击的是那一个 $('.info_content').mousemove(function(){ var ro ...
- Jquery AJAX使用踩坑小记
在使用jquery ajax时,如果其参数是一个json对象,将此参数使用$('#dd').data(param)绑定到一个元素上, 在使用$('#dd').bind('click',function ...
- C# 操作字符串,在某些特定的字符后面或前面添加其它字符
C# 操作字符串,在某些特定的字符后面或前面添加其它字符,解决方法: 字符串替换或正则表达式替换即可. 示例:实现的是在每个“第”前面添加一个逗号,在每个“方案”后面添加一个冒号. string s ...
- ycsb模板介绍
#对应的mongodb uri参数等mongodb.url=mongodb://127.0.0.1:27010/test_1 #对应的mongo数据库名称mongodb.database=test_1 ...
- Could not load OpenSSL解决
问题 Could not load OpenSSL. You must recompile Ruby with OpenSSL support or change the sources in you ...