KK's Point
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 350 Accepted Submission(s): 121
Total Submission(s): 350 Accepted Submission(s): 121
Problem Description
Our lovely KK has a difficult mathematical problem:He points
N(2≤N≤105) points on a circle,there are all different.Now he's going to connect the
N points with each other(There are no three lines in the circle to hand over a point.).KK wants to know how many points are there in the picture(Including the dots of boundary).
Input
The first line of the input file contains an integer
T(1≤T≤10), which indicates the number of test cases.
For each test case, there are one lines,includes a integer N(2≤N≤105),indicating the number of dots of the polygon.
For each test case, there are one lines,includes a integer N(2≤N≤105),indicating the number of dots of the polygon.
Output
For each test case, there are one lines,includes a integer,indicating the number of the dots.
Sample Input
2 3 4
Sample Output
3 5
Source
有交点需要有3个或者4个点,三个点的话,交点就是有公共点,相交的更像是一个角,四个点的话就是两天直线相交,因为题中说两两相交,那说明每一条线都会跟其他的线相交,并且不会有重复的交点,显然就是组合数C(4,4)+n,但是数据范围比较大,所以需要unsigned long long
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
unsigned long long n;
cin>>n;
unsigned long long temp=n*(n-1)*(n-2)/6*(n-3)/4+n;
cout<<temp<<endl;
}
return 0;
}