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

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
题意:n个不同的点 两点画一条线 最多两条线交于一点 问最多有多少个交点 包括边界点
 
题解

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

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

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

最后我们再把边界上的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;
}

  

hdu 5621的更多相关文章

  1. BestCoder Round #71 (div.2) (hdu 5621)

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

  2. hdu 5621 KK's Point(数学,推理题)

    题解: 在圆上点三个点时,除圆上三个交点外,圆内没有交点:在圆上点四个点时,除圆上四个交点外,圆内出现了一个交点,因此,在N个点中每四个点便可以在圆内产生一个交点,因此N个点在圆内形成的点的个数为CN ...

  3. HDU 5621 KK's Point

    N个点中任意选取四个点,就能产生一个圆内的交点,所以圆内总共有C(N,4)个交点,圆上有N个,相加就可以了. 注意:组合数运算的时候会爆longlong,中间先除一下就可以了. #include &l ...

  4. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  5. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

  6. hdu 4859 海岸线 Bestcoder Round 1

    http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...

  7. HDU 4569 Special equations(取模)

    Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  8. HDU 4006The kth great number(K大数 +小顶堆)

    The kth great number Time Limit:1000MS     Memory Limit:65768KB     64bit IO Format:%I64d & %I64 ...

  9. HDU 1796How many integers can you find(容斥原理)

    How many integers can you find Time Limit:5000MS     Memory Limit:32768KB     64bit IO Format:%I64d ...

随机推荐

  1. 关于Python 中的 if 语句

    学习Python,最开始我们都是先从函数学起,Python教程中有很多函数,if算是其中之一. 可能最为人所熟知的编程语句就是 if 语句了.例如: >>> >>> ...

  2. 卡片游戏 (Throwing card away I,UVa10935)

    题目描述: 解题思路: 直接模拟 #include <iostream> using namespace std; ] ; int main(int argc, char *argv[]) ...

  3. 交换学生 (Foreign Exchange,UVa10763)

    题目描述: 解题思路: 开一个数组,读入一次交换两个数,如果最后数组不变,即符合匹配 #include<iostream> #include<cstdio> #include& ...

  4. PNG和PVR之间互相转换的脚本

    项目经常会将png和pvr之间互相转换,这里mark一个脚本,会将当前目录下的文件全部批量转换 png转换成pvr @echo off path %path%;"C:\Program Fil ...

  5. Memcache的客户端连接系列(二) Python

    关键词: Memcached   Python 客户端 声明:本文并非原创,转自华为云帮助中心的分布式缓存服务(Memcached)的用户指南.客户端连接方法通用,故摘抄过来分享给大家. Python ...

  6. dotnetframe的清理工具

    微软的产品一向不敢恭维,卸载都没有办法卸载干净,卸载又慢又不彻底,dotnet被我卸载之后还有注册表残留以至于无法重新安装. .NET Framework Cleanup Tool真的很好用,全部版本 ...

  7. LeetCode 120——三角形最小路径和

    1. 题目 2. 解答 详细解答方案可参考北京大学 MOOC 程序设计与算法(二)算法基础之动态规划部分. 从三角形倒数第二行开始,某一位置只能从左下方或者右下方移动而来,因此,我们只需要求出这两者的 ...

  8. LeetCode - 412. Fizz Buzz - ( C++ ) - 解题报告 - to_string

    1.题目大意 Write a program that outputs the string representation of numbers from 1 to n. But for multip ...

  9. Hadoop,MapReduce操作Mysql

    前以前帖子介绍,怎样读取文本数据源和多个数据源的合并:http://www.cnblogs.com/liqizhou/archive/2012/05/15/2501835.html 这一个博客介绍一下 ...

  10. ThinkPHP - 2 - SAE(新浪云)部署

    ThinkPHP3.2核心内置了对SAE平台的支持(采用了应用模式的方式),具有自己的独创特性,能够最大程度的使用ThinkPHP的标准特性,让开发人员感受不到SAE和普通环境的差别.甚至可以不学习任 ...