码迷,mamicode.com
首页 > 其他好文 > 详细

Star

时间:2014-12-16 21:03:50      阅读:234      评论:0      收藏:0      [点我收藏+]

标签:des   style   ar   io   os   sp   for   on   div   

Description

Overpower often go to the playground with classmates. They play and chat on the playground. One day, there are a lot of stars in the sky. Suddenly, one of Overpower’s classmates ask him: “How many acute triangles whose inner angles are less than 90 degrees (regarding stars as points) can be found? Assuming all the stars are in the same plane”. Please help him to solve this problem.

Input

The first line of the input contains an integer T (T≤10), indicating the number of test cases.

For each test case:

The first line contains one integer n (1≤n≤100), the number of stars.

The next n lines each contains two integers x and y (0≤|x|, |y|≤1,000,000) indicate the points, all the points are distinct.


Output

For each test case, output an integer indicating the total number of different acute triangles.

Sample Input

1
3
0 0
10 0
5 1000

Sample Output


题意:给出一系列的点,要求求出能够组成锐角三角形的个数,锐角三角形的判断为其中较短的两条边的长度的平方和大于最大的边的长度的平方;

<span style="font-size:14px;"># include <cmath>
# include <cstdio>
# include <iostream>
# include <algorithm>
using namespace std;

double p[110][2];

int main()
{
    int T,n;
    scanf("%d",&T);
    while(T--)
    {
        scanf("%d",&n);
        int i,j,k,ans=0;
        double a,b,c;
        for(i=0;i<n;i++)
            scanf("%lf%lf",&p[i][0],&p[i][1]);
        for(i=0;i< n-2;i++)
            for(j=i+1;j< n-1;j++)
                for(k=j+1;k< n;k++)
                {
                    a=(p[i][0]-p[j][0])*(p[i][0]-p[j][0])+(p[i][1]-p[j][1])*(p[i][1]-p[j][1]);
                    b=(p[j][0]-p[k][0])*(p[j][0]-p[k][0])+(p[j][1]-p[k][1])*(p[j][1]-p[k][1]);
                    c=(p[k][0]-p[i][0])*(p[k][0]-p[i][0])+(p[k][1]-p[i][1])*(p[k][1]-p[i][1]);
                    if(a+b>c && a+c>b && b+c>a )    ans++;
                }
        printf("%d\n",ans);
    }
    return 0;
}</span>


Star

标签:des   style   ar   io   os   sp   for   on   div   

原文地址:http://blog.csdn.net/rechard_chen/article/details/41964947

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!