KK's Point
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1175 Accepted Submission(s): 389
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
无奈--开始没看懂题意---
题意:
圆上n个点两两相连,求一共最多有多少个交点--
原来有n个是三点两两相交连成的--然后至少需要四点形成两线交于圆内一点--
即C[ n ] [ 4 ]
代码“:
#include<cstdio>
void s()
{
unsigned __int64 n,s;
scanf("%I64u",&n);
if (n<4)
printf("%I64u\n",n);
else
printf("%I64u\n",n+n*(n-1)*(n-2)/2/3*(n-3)/4);
}
int main()
{
int t;scanf("%d",&t);
while (t--)
s();
return 0;
}