ACM训练联盟周赛 G. Teemo's convex polygon
- 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的更多相关文章
- 计蒜客 28449.算个欧拉函数给大家助助兴-大数的因子个数 (HDU5649.DZY Loves Sorting) ( ACM训练联盟周赛 G)
ACM训练联盟周赛 这一场有几个数据结构的题,但是自己太菜,不会树套树,带插入的区间第K小-替罪羊套函数式线段树, 先立个flag,BZOJ3065: 带插入区间K小值 计蒜客 Zeratul与Xor ...
- 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训练联盟周赛 第一场 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训练联盟周赛 Teemo's formula
Teemo has a formula and he want to calculate it quickly. The formula is . As the result may be very ...
- ACM训练联盟周赛(第一场)
B:Zeratul与Xor 题目描述 Xor(按位异或),对应C++中的“^”运算符. Zeratul给出了一个数列A[n](n≤105),要做q(q≤105)组动作,这些动作包括: 1 a:数列中 ...
随机推荐
- Day2课后作业:购物车简单版
PRODUCT_LIST = [ ['iphone7',6500], ['macbook',12000], ['pythonbook',66], ['bike',999], ['coffee',31] ...
- Influxdb 时序数据库 windows 安装
Influxdb 是一款比较火爆的时序数据库,本文介绍如何在 windows 平台下安装. 1.场景: windows 平台的 influxdb 似乎只支持单机非windows 服务的安装方式 适用于 ...
- Jasper_crosstab_group_dataset_Error incrementing crosstab dataset
Error detail: net.sf.jasperreports.engine.JRException: net.sf.jasperreports.engine.JRRuntimeExceptio ...
- vs2013缺少Mvc 怎么办?
命名空间System.Web中不存在类型或命名空间名称Mvc是否缺少程序集引用? 以前vs2010或2012以前的引用一下就有了,为何现在vs2013没有,该这么处理呢?? 解决方案: 打开PCM: ...
- Unity Shader入门精要学习笔记 - 第12章 屏幕后处理效果
建立一个基本的屏幕后处理脚本系统 屏幕后处理,顾名思义,通常指的是在渲染完整个场景得到屏幕图像后,再对这个图像进行一系列操作,实现各种屏幕特效.使用这种技术,可以为游戏画面添加更多艺术效果,例如景深. ...
- 如何查看和分析IIS日志
日志的在IIS中是很重要的,但是很多人却忽略了,在这里说说,日志格式建议使用W3C扩充日志文件格式,这也是IIS 5.0默认的格式,可以指定每天记录客户IP地址.用户名.服务器端口.方法.URI资源. ...
- 開玩樹莓派(一):安裝Raspbian系統
目錄: 開玩樹莓派(一):安裝Raspbian系統 開玩樹莓派(二):配置IP,實現無顯示器局域網內Putty連接和RDP遠程 開玩樹莓派(三):Python編程 開玩樹莓派(四):GPIO控制和遠程 ...
- maven创建springMVC项目(一)
1.Eclipse配置 添加maven集成安装包:路径是maven下载安装的解压位置,如果不知道如何下载安装请点击这里看我的另一篇安装文章,这里不多说 这里需要注意的是: a.settings.xml ...
- WebService学习之旅(六)使用Apache Axis2实现WebService客户端调用
上节介绍了如何使用Axis2 发布一个WebService,Axis2除了为我们编写WebService应用带来了便利,也同样简化的客户端调用的过程,本节在上节的基础上使用Axis2自带的工具生成客户 ...
- 面向 AWS 专家的 Azure 云服务介绍
本文是面向 AWS 专家的 Azure 云服务介绍,参考本文可以帮助大家“按图索骥”在 Azure 的平台上找到能满足自己需求的服务. 公有云市场经过多年发展,已经涌现出几家大规模的提供商,如 Azu ...