多少个交点

来源:互联网 发布:足彩数据分析软件 编辑:程序博客网 时间:2024/05/17 04:47

Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other)
Total Submission(s) : 43   Accepted Submission(s) : 22

Font: Times New Roman | Verdana | Georgia

Font Size:  

Problem Description

现在有一个很大的圆,圆周上有很 N 点,让这 N 个点两两连线,问连线有多少条,这
些连线在圆的内部有多少个交点

Input

多组输入,每行输入一个数字表示 N(1 ≤ N ≤ 100);

Output

输出两个数字,第一个数字表示连线的条数,第二个数字表示园内交点的个数。

Sample Input

24

Sample Output

1 06 1Hint 排列组合

解题说明:排列组合题目,圆内交点个数为C (N, 4)

#include <iostream>#include <stdio.h>#include <string.h>using namespace std; int main(){    int n;    while(cin>>n){        int m;        m=((n-1)*n)/2;        cout<<m<<" ";        if(n<4)            cout<<"0"<<endl;        else            cout<<n*(n-1)*(n-2)*(n-3)/24<<endl;    }    return 0;}