• 65536K
 

Teemo is very interested in convex polygon. There is a convex n-sides polygon, and Teemo connect every two points as diagonal lines, and he want to kown how many segments which be divided into intersections. Teemo ensure that any three diagonals do not intersect at a point.

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 100.

For each test case, the first line contains an integer n(3<=n<=10^18).

Output Format

For each test case, output a line containing an integer that indicates the answer.

样例输入

2
3
4

样例输出

0
4
 #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
void egcd(ll a,ll b,ll &x,ll &y)
{
ll d=a;
if(!b) {
x=;y=;
return ;
}
else{
egcd(b,a%b,y,x);
y-=(a/b)*x;
}
}
ll inv(int n){
ll x,y;
egcd(n,mod,x,y);
return (x%mod+mod)%mod;
}
int t;
ll n;
/*
//任意三个无交点
n*(n-3) : 凸多边形的每个顶点与其他的点连接形成的线段数目
4*C(n,4) : 4个点形成形内1顶点,而1个点出现4个分割的线段
都出现了两次
(C(n,4)*4+n*(n-3))/2
/
int main()
{
scanf("%d",&t);
while(t--)
{
scanf("%lld",&n);
n%=mod;//避免溢出
ll ans=n*(n-3)%mod*(8+n*n%mod-3*n%mod+mod)%mod*inv(12)%mod;
printf("%lld\n",ans);
}
return 0;
}

ACM训练联盟周赛 G. Teemo's convex polygon的更多相关文章

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

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

  2. 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 ...

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

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

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

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

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

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

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

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

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

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

  8. ACM训练联盟周赛 Teemo's formula

    Teemo has a formula and he want to calculate it quickly. The formula is . As the result may be very ...

  9. ACM训练联盟周赛(第一场)

    B:Zeratul与Xor 题目描述 Xor(按位异或),对应C++中的“^”运算符. Zeratul给出了一个数列A[n](n≤105),要做q(q≤105)组动作,这些动作包括: 1  a:数列中 ...

随机推荐

  1. Python开发 第01课 Python 简介

    一.Python 介绍 python的创始人为吉多·范罗苏姆(Guido van Rossum).1989年的圣诞节期间,吉多·范罗苏姆为了在阿姆斯特丹打发时间,决心开发一个新的脚本解释程序,作为AB ...

  2. centos7版本对比之前版本的部分命令差异

    centos7版本下的命令和之前的centos版本的命令有些许不同,最近在电脑上用VBox安装了一个centos7版本.在做一些网卡配置和安装mysql的时候遇到了一些问题.在这里总结跟大家分享下. ...

  3. linux 打开FTP 功能

    http://blog.csdn.net/jay285979220/article/details/62216622 今天在linux上安装完了vsftpd后,使用root账号一直无法登陆到服务器上. ...

  4. python学习之高级特性:

    切片:对列表.元组.字符串.字典取中间的一部分,在C中一般是通过for循环拷贝/memcpy/strcat等操作.而python提供了更方便的切片操作符[m:n]:前闭后开,如果从0取m可以省略:如果 ...

  5. [已读]悟透JavaScript

    这本书出的特别早,就第一部分内容还行,第一次看得时候觉得蛮有意思,讲禅的方式来讲javascript,作者造了一个"甘露模型"来实现继承,不过今天整理的时候,发现那些笔记都没多少可 ...

  6. HDU 3117 Fibonacci Numbers 数学

    http://acm.hdu.edu.cn/showproblem.php?pid=3117 fib是有一个数学公式的. 这里的是标准的fib公式 那么fib = 1 / sqrt(5) * ((1 ...

  7. shell与aw的简单交互示例

    先来看一段shell代码 word=“a test name” selectword=“test"lineitem=`echo "$word" | awk 'match( ...

  8. [转]Android应用自动更新功能的代码实现

    本文转自:http://www.cnblogs.com/coolszy/archive/2012/04/27/2474279.html 由于Android项目开源所致,市面上出现了N多安卓软件市场.为 ...

  9. Autofac框架使用遇到的问题

    1) 安全透明方法“Autofac.Integration.Mvc.RegistrationExtensions.RegisterControllers(Autofac.ContainerBuilde ...

  10. iOS之创建CocoaPods公有库教程

    简介 在开发过程中,经常会使用到第三框架,我们通过一个pod install命令,很方便的就将第三方框架加到我们自己的项目中. 如果我们也想将自己写的组件或库开源出去,让别人也可以通过pod inst ...