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



  • 相关阅读:
    声律启蒙(上 下卷,珍藏版)
    笠翁对韵(全卷,珍藏版附注释)
    Oracle 中 nvl、nvl2、nullif、coalesce、decode 函数的用法详解
    Groovy
    spring各版本jar包和源码
    Java 调用翻译软件实现英文文档翻译
    oracle导出序列的几种办法
    Oracle数据库内存使用情况分析查看
    window Maven私服搭建——nexus
    用户管理的备份与恢复
  • 原文地址:https://www.cnblogs.com/playboy307/p/5273468.html
Copyright © 2020-2023  润新知