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. 基于 CPython 解释器,为你深度解析为什么Python中整型不会溢出

    前言 本次分析基于 CPython 解释器,python3.x版本 在python2时代,整型有 int 类型和 long 长整型,长整型不存在溢出问题,即可以存放任意大小的整数.在python3后, ...

  2. 41. Maximum Subarray

    Description Given an array of integers, find a contiguous subarray which has the largest sum. The su ...

  3. (python)leetcode刷题笔记 01 TWO SUM

    1. Two Sum Given an array of integers, return indices of the two numbers such that they add up to a ...

  4. (转)Shadow Mapping

    原文:丢失,十分抱歉,这篇是在笔记上发现的.SmaEngine 阴影和级联部分是模仿UE的结构设计   This tutorial will cover how to implement shadow ...

  5. oracle数据库之PL/SQL 流程控制语句

    介绍 PL/SQL 的流程控制语句, 包括如下三类: 1.控制语句: IF 语句 2.循环语句: LOOP 语句, EXIT 语句 3.顺序语句: GOTO 语句, NULL 语句 一 条件语句 IF ...

  6. HDU 5816 Hearthstone 概率dp

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5816 Hearthstone Time Limit: 2000/1000 MS (Java/Othe ...

  7. Web后台任务处理

    文章:.NET Core开源组件:后台任务利器之Hangfire Hangfire官网介绍:在.NET和.NET Core应用程序中执行后台处理的简便方法.无需Windows服务或单独的过程. 以持久 ...

  8. Alpha-5

    前言 失心疯病源5 团队代码管理github 站立会议 队名:PMS 530雨勤(组长) 今天完成了那些任务 14:30~15:30 阅读blob分析相关论文,找到一篇很早年的论文,但是作者讲解十分细 ...

  9. SQL 跨库查询

    使用SQL查询数据,不仅能查询当前库的数据,还可以跨数据库,甚至跨服务器查询. 下面给大家介绍一下跨服务器查询的步骤(以SQL Server为例): 1,建立数据库链接 EXEC sp_addlink ...

  10. 【转载】用C#编写一个简单的记事本

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...