zoukankan      html  css  js  c++  java
  • 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 Submission(s): 644    Accepted Submission(s): 220


    Problem Description
    Our lovely KK has a difficult mathematical problem:He points N(2N105) 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(1T10), which indicates the number of test cases.

    For each test case, there are one lines,includes a integer N(2N105),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);
    			continue;
    		}
    		unsigned long long ans=n*(n-1)/2*(n-2)/3*(n-3)/4+n;
    		printf("%llu
    ",ans);
    	}
    	return 0;
    }
    

      

  • 相关阅读:
    IT English Collection(16) of Message
    TO DO NOW——送给奋斗着的程序“猿”们
    题目:[NOIP1999]拦截导弹(最长非递增子序列DP) O(n^2)和O(n*log(n))的两种做法
    hdu 1695 GCD
    paip.提升用户体验---c++ qt 取消gcc编译的警告信息.txt
    hive优化要点总结
    HDU 4099 Revenge of Fibonacci (数学+字典数)
    JSP小实例--计算器
    关于产品的一些思考——百度之百度百科
    正则表达式JSP实例
  • 原文地址:https://www.cnblogs.com/tonghao/p/5189016.html
Copyright © 2011-2022 走看看