KK's Point

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

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

题意:一个圆上给n个点,将这些点两两相连,问有多少个交点

要求:1、圆上的点也算   2、圆内只有两条线的交点,没有两条以上线的交点

题解:圆上的点为n个,我们只需计算圆内有多少个交点即可,4个点可以在圆内形成一个交点,所以我们计算n个点可以组成多少个四边形即可

求解组合公式C(n,4)+n;

#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<queue>
#define MAX 100100
#define INF 0x3f3f3f
using namespace std;
int main()
{
int t;
unsigned long long n;
scanf("%d",&t);
while(t--)
{
scanf("%llu",&n);
if(n<4)
{
printf("%llu\n",n);
continue;
}
unsigned long long ans=n*(n-1)/2*(n-2)/3*(n-3)/4+n;
printf("%llu\n",ans);
}
return 0;
}

  

BestCoder Round #71 (div.2) (hdu 5621)的更多相关文章

  1. BestCoder Round #71 (div.2) (hdu 5620 菲波那切数列变形)

    KK's Steel Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total ...

  2. BestCoder Round #73 (div.2)(hdu 5630)

    Rikka with Chess Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) ...

  3. Codeforces Round #316 (Div. 2) (ABC题)

    A - Elections 题意: 每一场城市选举的结果,第一关键字是票数(降序),第二关键字是序号(升序),第一位获得胜利. 最后的选举结果,第一关键字是获胜城市数(降序),第二关键字是序号(升序) ...

  4. hdu 5424 Rikka with Graph II (BestCoder Round #53 (div.2))(哈密顿通路判断)

    http://acm.hdu.edu.cn/showproblem.php?pid=5424 哈密顿通路:联通的图,访问每个顶点的路径且只访问一次 n个点n条边 n个顶点有n - 1条边,最后一条边的 ...

  5. BestCoder Round #69 (div.2)(hdu5611)

    Baby Ming and phone number Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 65536/65536 K (Ja ...

  6. BestCoder Round #71 (div.2)

    数学 1001 KK's Steel 类似斐波那契求和 #include <cstdio> #include <cstring> #include <algorithm& ...

  7. Valentine's Day Round 1001.Ferries Wheel(hdu 5174)解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5174 题目意思:给出 n 个人坐的缆车值,假设有 k 个缆车,缆车值 A[i] 需要满足:A[i−1] ...

  8. Codeforces Round #240 (Div. 2)(A -- D)

    点我看题目 A. Mashmokh and Lights time limit per test:1 secondmemory limit per test:256 megabytesinput:st ...

  9. BestCoder Round #36 (hdu5199)Gunner(水题)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Gunner Time Limit: 8000/4000 MS (Java/Oth ...

随机推荐

  1. sdut 1728 编辑距离问题( dp )

    题目 思路:edit(i, j),它表示第一个字符串的长度为i的子串到第二个字符串的长度为j的子串的编辑距离. 有如下动态规划公式: if i == 0 且 j == 0,edit(i, j) = 0 ...

  2. bzoj1913

    这是一道好题,要求每个三点圆覆盖的点数和 我们可以算四边形的贡献,四边形显然分成两种:凸四边形和凹四边形 显然,凹四边形的覆盖只可能是三个点组成三角形包含另一个点,所以贡献是1 凸四边形,其最小圆覆盖 ...

  3. hdu 4635 Strongly connected(强连通)

    考强连通缩点,算模板题吧,比赛的时候又想多了,大概是不自信吧,才开始认真搞图论,把题目想复杂了. 题意就是给你任意图,保证是simple directed graph,问最多加多少条边能使图仍然是si ...

  4. 【C#学习笔记】自我复制

    using System; using System.IO; using System.Diagnostics; namespace ConsoleApplication { class Progra ...

  5. 关于web安全

    从技术到安全, 这是一个趋势. 以前追求的是比较炫酷的技术, 等实现过后发现, 自己还能做什么. 炫技完了之后,差不多就该到悟道的时候了. 用户安全, 就是一个很大的禅. 苹果拒绝 FBI, goog ...

  6. jQuery点击div其他地方隐藏div

    $(document).bind("click",function(e){ var target = $(e.target); ){ $("#regionlist&quo ...

  7. Asp.net 将DataTable 或者DataSet 转换为Json 格式

    Web 开发中,将从数据库中取到的数据直接转换为 Json 格式的数据,在前台通过Ajax 无刷新显示在界面上,下面提供将DataTable 或者DataSet 转换为Json 的方法 /// < ...

  8. Python easy_install

    系统中有高版本的Python, 直接pip3 install ipcalc安装,都是装到高版本的Python 系统默认的Python是2.7.6,现在想装到默认版本中,可以使用easy_install ...

  9. Win10遇上Kindle就蓝屏

    在使用 Kindle 连接 Win10 时会出现蓝屏现象,现在,微软承认 Windows 10 插入 Kindle 导致蓝屏问题,并表示目前正着手制作补丁.微软表示:“我们承认确实存在当Kindle ...

  10. Easy Climb

    题意: 有n块石头,给定他们的高度,现保持第一和最后一块高度不变,其他可增加和减少高度,求通过变换使所有相邻石头的高度差的绝对值不大于d,所变化高度总和的最小值. 分析: 状态还可以想出来,dp[i] ...