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:数列中 ...
随机推荐
- HTML超链接的使用
基本语法 <a href="" target="打开方式" name="页面锚点名称">链接文字或图片</a> 属性 ...
- Gym - 101147J Whistle's New Car 树上差分
J. Whistle's New Car time limit per test 15 seconds memory limit per test 512 megabytes input car.in ...
- vs 2017注册码 激活码
Visual Studio 2017(VS2017) 企业版 Enterprise 注册码:NJVYC-BMHX2-G77MM-4XJMR-6Q8QFVisual Studio 2017(VS2017 ...
- FTP上传下载 C#辅助类
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.N ...
- linux安装redis官方教程
官方链接:http://redis.io/download Download, extract and compile Redis with: $ wget http://download.redis ...
- 一行JS搞定快速关机
一.在本地新建一个文件js文件 JS代码: (new ActiveXObject("Shell.Application")).ShutdownWindows(); 二.设置快捷键 ...
- LR11安装和配置教程
LoadRunner11安装教程 #安装包文件.汉化文件.破解文件,可以自行百科来获得,这边仅提供安装步骤. 1.前期准备1)安装前需要关闭防火墙及杀毒软件2)安装路径不能包含中文字符,同时需要以管理 ...
- (转)SpringMVC学习(四)——Spring、MyBatis和SpringMVC的整合
http://blog.csdn.net/yerenyuan_pku/article/details/72231763 之前我整合了Spring和MyBatis这两个框架,不会的可以看我的文章MyBa ...
- Google Colab免费GPU使用教程(一)
一.前言 现在你可以开发Deep Learning Applications在Google Colaboratory,它自带免费的Tesla K80 GPU.重点是免费.免费!(国内可能需要tz) 这 ...
- js 控制台输出
var a = 'string'; var b = 123; console.log("The %s jumped over %d tall buildings", a, b); ...