zoukankan      html  css  js  c++  java
  • hdoj--5621--KK's Point(简单数学)

    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(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
     

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



  • 相关阅读:
    [算法整理]树上求LCA算法合集
    线段树专题测试2017.1.21
    [数据结构]替罪羊树简介
    图论测试 2017.1.17
    bzoj 2038 A-小Z的袜子[hose]
    洛谷比赛『期末考后的休闲比赛2』
    [题解]bzoj 1861 Book 书架
    bzoj 3223 文艺平衡树
    Splay简介
    python2.7 一个莫名其妙的错误
  • 原文地址:https://www.cnblogs.com/playboy307/p/5273468.html
Copyright © 2011-2022 走看看