star

Problem 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

1
题意:给定n个点,判断能组成多少个锐角三角形
题解:向量的坐标运算,直接判断即可,比赛时考虑了全等wrong到哭
#include<stdio.h>
#include<iostream>
#define ll __int64
using namespace std;
struct lmx{
   ll x;
   ll y;
};
lmx lm[101];
bool is(lmx l1,lmx l2,lmx l3)
{
 if((l2.y-l1.y)*(l3.x-l2.x)==(l3.y-l2.y)*(l2.x-l1.x)||(l2.y-l1.y)*(l3.x-l2.x)+(l3.y-l2.y)*(l2.x-l1.x)==0) return false;
 if((l2.x-l1.x)*(l3.x-l1.x)+(l2.y-l1.y)*(l3.y-l1.y)<0) return false;
 if((l1.x-l2.x)*(l3.x-l2.x)+(l1.y-l2.y)*(l3.y-l2.y)<0) return false;
 if((l1.x-l3.x)*(l2.x-l3.x)+(l1.y-l3.y)*(l2.y-l3.y)<0) return false;
 return true;
}
int main()
{
 ll n,i,j,k,test,cnt;
 scanf("%I64d",&test);
 while(test--)
 {
  scanf("%I64d",&n);
  cnt=0;
  for(i=0;i<n;i++)
  {
   scanf("%I64d %I64d",&lm[i].x,&lm[i].y);
  }
  for(i=0;i<n-2;i++)
  {
   for(j=i+1;j<n-1;j++)
   {
               for(k=j+1;k<n;k++)
      {
       if(is(lm[i],lm[j],lm[k])) cnt++;
      }
   }
  }
  printf("%I64d\n",cnt);
 }
 return 0;
}
posted @ 2013-09-24 21:06  forevermemory  阅读(233)  评论(0编辑  收藏  举报