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

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.
 
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;
}

最新文章

  1. S5PV210_流水灯
  2. PyCharm3.0默认快捷键(翻译的)
  3. 快速排序算法 java 实现
  4. Random
  5. JSP 4个域对象-9个内置对象-11个EL隐式对象
  6. JQuery:JQuery遍历详解
  7. treap树及相关算法
  8. Git 设置别名[alias]
  9. JavaScript typeof obj === ‘object’ 这样写有什么问题
  10. Android EditText小结
  11. MATLAB中return和break
  12. Java-WebSocket 项目的研究(三) WebSocketClient 类 具体解释
  13. Java中实现String.padLeft和String.padRight
  14. 【Django】git建仓上传时遇到的小问题
  15. [flask]gunicorn配置文件
  16. Java实现数据库与eclipse的连接
  17. 6.ST LINK 下调试异常
  18. hive进行词频统计
  19. 分析Linux上的程序依赖
  20. 【RS】Stochastic PCA with ℓ2 and ℓ1 Regularization - ℓ2 和 ℓ1正则的随机 PCA

热门文章

  1. Android第三方登陆之新浪微博Weibo篇(原生登陆授权)
  2. ionic + cordova开发APP遇到的一些坑
  3. 需要知道的TCP/IP三次握手
  4. 【sqli-labs】 less27a GET- Blind based -All you Union&amp;Select Belong to us -Double Quotes(GET型基于盲注的去除了Union和Select的双引号注入)
  5. C# 去掉代码前边空格(格式化代码)
  6. Memcached 之内存管理与删除机制
  7. Appium Desired Capabilities信息配置
  8. 【编程工具】Vim编辑器的使用
  9. Python学习【第1篇】:环境配置
  10. 爬虫系列(十一) 用requests和xpath爬取豆瓣电影评论