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; }
相关文章推荐
- YTU 2697: 血型统计
- eclipse配置安卓环境(mac系统)
- 程序只运行一个实例,并激活已运行的程序
- Unity3D NGUI,uGUI总结
- YTU 2690: 用双重循环实现小九九
- 1.以普通表格型单表为模板定制模块:短信分类维护
- YTU 2677: 韩信点兵
- ipvs负载均衡(三)ipvs三种工作方式
- 嵌入式Linux系统的电子书阅读器项目2——Display System
- YTU 2642: 填空题:类模板---求数组的最大值
- STL之string
- YTU 2641: 填空题:静态成员---计算学生个数
- Python成长之路第二篇(1)_数据类型内置函数用法
- [5] CMake总结 - 2 基本命令
- YTU 2640: 编程题:运算符重载---矩阵求和
- YTU 2639: 改错题:类中私有成员的访问
- 需求 - 17 - “录制圈”
- YTU 2636: B3 指向基类的指针访问派生类的成员函数
- YTU 2635: P4 游戏中的Human角色
- 椭圆形的窗体