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


#include<stdio.h>
#include<math.h>
typedef struct nn
{
double x1,y1;
}node;
void cmp(double *a,double *b,double *c)
{
double tem;
if(*a<*b){tem=*a;*a=*b;*b=tem;}
if(*a<*c){tem=*a;*a=*c;*c=tem;}
}
double cacreat(double x1,double y1,double x2,double y2)
{
double edglen;
edglen=sqrt(pow(x1-x2,2.0)+pow(y1-y2,2.0));
return edglen;
}
int pandu(double a,double b,double c)
{
if(b*b+c*c-a*a>0)
return 1;
return 0;
}
double x[105],y[105];
node s[3];
int vist[105],n,sum;
void dfs(int cout,int j)
{
double edg1,edg2,edg3;
int i;
s[cout].x1=x[j];s[cout].y1=y[j];
if(cout==2)
{
edg1=cacreat(s[0].x1,s[0].y1,s[1].x1,s[1].y1);
edg2=cacreat(s[0].x1,s[0].y1,s[2].x1,s[2].y1);
edg3=cacreat(s[1].x1,s[1].y1,s[2].x1,s[2].y1);
cmp(&edg1,&edg2,&edg3);
if(pandu(edg1,edg2,edg3)!=0)
sum++;
return ;
}
for(i=j+1;i<n;i++)
if(vist[i]==0)
{
vist[i]=1;
dfs(cout+1,i);
vist[i]=0;
}
}
int main()
{
int i,t;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%lf%lf",&x[i],&y[i]);
vist[i]=0;
}
sum=0;
for(i=0;i<n;i++)
{
vist[i]=1;
dfs(0,i);
vist[i]=0;
}
printf("%d\n",sum);
}
}

最新文章

  1. Cucumber
  2. 原来MySQl就是这样工作的!
  3. (easy)LeetCode 205.Isomorphic Strings (*)
  4. javascript删除目标标签
  5. Networking
  6. OpenStreetMap初探(一)——了解OpenStreetMap
  7. git push origin master 报错 remote rejected] master -&gt; master (branch is currently checked out)
  8. vue 中获取select 的option的value 直接click?
  9. TestNg和spring3测试报错:Failed to read candidate component class-遁地龙卷风
  10. npm 相关命令
  11. Golang查缺补漏(一)
  12. Ubuntu 使用命令行连接无线网
  13. iOS逆向工程之Cycript
  14. meta 跳转
  15. JavaScript 隐式类型转换之:加号+
  16. imx6 android5.1 编译
  17. java 面向对象 — 类和对象
  18. Golang教程:并发介绍
  19. redis 在java中的使用
  20. [mongodb]child process failed, exited with error number 100

热门文章

  1. ZOJ 3603 Draw Something Cheat
  2. JavaScript 判断是否为undefined
  3. The Little Redis Book
  4. Spring AOP实现方式二【附源码】
  5. 如何使用GetManifestResourceStream
  6. 【HDOJ】1075 What Are You Talking About
  7. tlplayer,wzplayer所有平台通用加密测试视频
  8. ADDED_TO_STAGE 多次被调用
  9. AS 学习笔记 加载数据
  10. iOS7 iOS8 毛玻璃效果的分别实现