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

FZOJ2110 star(DFS)的更多相关文章

  1. FZOJ2110: Star

    Problem Description Overpower often go to the playground with classmates. They play and chat on the ...

  2. [JSOI2008]Star War

    星球之间互相直接或间接地连接帝国开始使用死星有计划地摧毁反抗军占领的星球给出星球间隧道的连通情况,已经帝国打击的顺序要求以尽量快的速度求出每一次打击之后反抗军占据的星球的联通快的个数(若两个星球,直接 ...

  3. 蓝桥杯PREV-12(dfs&割点)

    题目链接:http://lx.lanqiao.cn/problem.page?gpid=T35 题意:中文题诶- 思路:dfs 假设star 和 end之间总路径数目为ans, 那么若经过路径上某点到 ...

  4. 笔试算法题(48):简介 - A*搜索算法(A Star Search Algorithm)

    A*搜索算法(A Star Search Algorithm) A*算法主要用于在二维平面上寻找两个点之间的最短路径.在从起始点到目标点的过程中有很多个状态空间,DFS和BFS没有任何启发策略所以穷举 ...

  5. dfs 二叉树中序遍历迭代解法——求解BST中第k小元素

    BST中第K小的元素 中文English 给一棵二叉搜索树,写一个 KthSmallest 函数来找到其中第 K 小的元素. Example 样例 1: 输入:{1,#,2},2 输出:2 解释: 1 ...

  6. hdu4081 最小树+DFS或者次小树的变形

    题意:       给你一个全图,在里面找到一棵树,这棵树最多只有一条边可以不是最小树(也可以是), 要求 那对特殊的边的两个权值/除了这条边其他边的和最大. 思路:      方法有很多,最少有三种 ...

  7. hdu 4309 最大流 + DFS

    题意:      给以三种有向边     (1) 隧道,可以过无数人,也可以藏c个人.     (2) 路,只能过人(流量INF).     (3)古桥,如果不修理可以过1个人,修理可以过无数个人,但 ...

  8. NOIP模拟测试24「star way to hevaen·lost my music」

    star way to heaven 题解 大致尝试了一下并查集,记忆化搜索,最小生成树 最小生成树是正解,跑最小生成树然后找到最大的值 欧几里德距离最小生成树学习 prim楞跑 至于为什么跑最小生成 ...

  9. 7.15考试总结(NOIP模拟16)[Star Way To Heaven·God Knows·Lost My Music]

    败者死于绝望,胜者死于渴望. 前言 一看这个题就来者不善,对于第一题第一眼以为是一个大模拟,没想到是最小生成树. 对于第二题,先是看到了状压可以搞到的 20pts 然后对着暴力一顿猛调后来发现是题面理 ...

随机推荐

  1. 来看看Meteor的功能

    看了一上午,感觉这确实比所谓传统的APP开发,有很多不一样的地方. 记录下来: simple-todos.css /* CSS declarations go here */ /* CSS decla ...

  2. 这个帖子要收藏,以后用得着--python 实时获取子进程输出

    在论坛上找到方法了,http://bbs.csdn.net/topics/340234292 http://blog.csdn.net/junshao90/article/details/821575 ...

  3. POJ2221+模拟

    参考http://blog.sina.com.cn/s/blog_7de5c6210100tm1h.html 其实是水题............ #include<string.h> #i ...

  4. [杂题]CSUOJ1274Balls and Boxes

    题目链接 题意:中文题 题意不多赘述 值得注意的是n<m 不必考虑n==m的情况 (m是盒子个数, n是每次选取的盒子个数, 不要弄反了!) 这题一看就是同余方程 每次选取n个盒子放球 也就是说 ...

  5. SQLite入门与分析(六)---再谈SQLite的锁

    写在前面:SQLite封锁机制的实现需要底层文件系统的支持,不管是Linux,还是Windows,都提供了文件锁的机制,而这为SQLite提供了强大的支持.本节就来谈谈SQLite使用到的文件锁——主 ...

  6. Two-Phase Locking

    两阶段封锁(Two-Phase Locking) 两段锁协议的内容 1. 在对任何数据进行读.写操作之前,事务首先要获得对该数据的封锁 2. 在释放一个封锁之后,事务不再获得任何其他封锁. “两段”锁 ...

  7. c while 循环

    c代码: #include <stdio.h> int main(void){ unsigned long sum=1UL; unsigned int j=1U; unsigned ; p ...

  8. make menuconfig出错

    make[1]: *** [scripts/kconfig/mconf] Error 1 make: *** [menuconfig] Error 2 fixed: sudo apt-get inst ...

  9. 函数 flst_get_first

    /********************************************************************//** Gets list first node addre ...

  10. 存储过程中“Select Top 变量”的问题如何解决

    在SqlServer2005中,可以这样: DECLARE @p int SELECT TOP (@p) * FROM 表名 在SqlServer2000中,不支持以上方法,可以这样: DECLARE ...