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的排 ...
 
随机推荐
- python Windows和Linux路径表示问题
			
Windows下路径是用‘\\’表示也可以使用'/',但是Linux下路径都是‘/’表示. 因为python是跨平台的,有时候程序迁移会出现错误. 解决办法1 可全部使用‘/’表示 解决办法2 我们可 ...
 - H5网站加载速度优化总结
			
1. 在代码文件结构 尽量优化的同时,能力再强已经到极限了,但你服务器辣鸡,搭配不当,你代码优化上天 也是徒劳啊. 2.你不怎么优化, 服务器 各种技术配置到位的话, now你也看到了,我一个系统首页 ...
 - AFNetworking 一般用法
			
AFNetworking是一个用于iOS.macOS.watchOS和tvOS的功能强大的网络库.它构建在基础URL加载系统之上,扩展了强大的高级网络抽象,并将其构建为Cocoa.它有一个模块化的架构 ...
 - 基于H5+ API手机相册图片压缩上传
			
// 母函数 function App(){} /** * 图片压缩,默认同比例压缩 * @param {Object} path * pc端传入的路径可以为相对路径,但是在移动端上必须传入的路径是照 ...
 - 设置umask
			
umask 002 例子:umask为003,建立的文件与目录权限是什么? umask为003,所有去掉的属性为-------wx,因此 文件 -rw-rw-r-- 目录 drwxrwxr--
 - Visual SVN IIS反向代理设置
			
需要解决的问题: 1. 设置反向代理 2. 解决部分后缀文件无法提交的问题 1. 设置反向代理 接收所有的URL 允许所有的HTTP_HOST 跳转到被代理的服务器 2. 允许所有后缀的文件访问IIS ...
 - 【Web应用-网络连接】Azure Web 应用对外连接数上限分析
			
在 Azure Web 应用中发起大量外部连接操作时,需要考虑已经建立了多少外部连接.当超过最大对外连接数时,Azure Web 应用将会产生套接字异常.Azure Web 应用对于各个级别的实例,对 ...
 - LR中操中MySQL脚本模板
			
Action(){ char chQuery[128]; MYSQL *Mconn; int result; //引入mysql动态链接库 lr_load_dll("libmysql.dll ...
 - Linux中grep、sed、awk使用介绍
			
linux文件操作命令介绍1)grepgrep 用于在文件中查找符合条件的记录grep 参数 过滤条件 文件过滤的条件中可使用正则表达式-c 显示符合的行数-i 忽略大小写-n 显示符合要求的记录,包 ...
 - php随机生成国内ip地址
			
获得一个国家所有ip段,随机生成国内ip地址的缩水实现.注意: $ip_long数组中后5个值在64位系统中可能是错误的(下面代码中 $ip_long 数组的后五个值在32位系统中为负数,64位系 ...