您的位置:首页 > 其它

hdu 5621

2016-02-08 13:07 225 查看

KK's Point

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 357 Accepted Submission(s): 124


[align=left]Problem Description[/align]
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).

[align=left]Input[/align]
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.

[align=left]Output[/align]
For each test case, there are one lines,includes a integer,indicating the number of the dots.

[align=left]Sample Input[/align]

2
3
4

[align=left]Sample Output[/align]

3
5

[align=left]Source[/align]
BestCoder Round #71 (div.2)
题意:n个不同的点 两点画一条线 最多两条线交于一点 问最多有多少个交点 包括边界点

题解
我们先撇开边界上的点不管,那么所有的点都是有两条线所构成的

手算得出N=4的时候,能形成一个点

那么,我们只要知道N个点可以构成几个四边形即可 C(4,n)​​

最后我们再把边界上的N个点加上

bc 结束了交了几遍wa 爆long long

改用 usigned long long

#include<iostream>
#include<cstring>
#include<cstdio>
#define LL unsigned long long
using namespace std;
LL t;
LL n;
int main()
{

while(scanf("%I64d",&t)!=EOF)
{
for(LL i=1; i<=t; i++)
{
scanf("%I64d",&n);
printf("%I64u\n",n+n*(n-1)/2*(n-2)/3*(n-3)/4);
}
}
return 0;
}


  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: