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. String类的split方法以及StringTokenizer

    split方法可以根据指定的表达式regex将一个字符串分割成一个子字符串数组. 它的参数有两种形式,也即:split(String regex)和split(String regex, int li ...

  2. 对于 APM 用户的一次真实调查分析(下)

    一.前言 对 APM 用户的一次真实调查分析(上)中,我们主要聊到了现阶段国外 APM 行业对各个企业的渗透率.大部分使用 APM 工具的企业规模以及 APM 工具在用户心中的地位等问题,有兴趣的朋友 ...

  3. *[codility]MaxCounters

    http://codility.com/demo/take-sample-test/maxcounters 简单题.注意要记录两个max,一个是最大值,一个是已经生效的最大值. // you can ...

  4. QT使用UAC(经过验证)

    网上有很多manifest的版本,mingw与vs系列也有不同的解决方案,不管那么多,我是使用这篇文章解决这个问题的: So it turns out that I had another bug t ...

  5. int指令理解

    以下是王爽老师的<汇编语言>中第十五章中的一段程序代码,其功能是增加9号中断的功能,当按下Esc键时屏幕中显示的字母改变颜色 assume cs:codesg,ss:stack,ds:da ...

  6. Sublime Text各种插件使用方法

    有快捷键冲突的时候可以修改快捷键,建议修改插件快捷键而不是Sublime Text的快捷键,我的有冲突的一律将插件快捷键设置成:Ctrl+Alt+A(B...) Package Control 通俗易 ...

  7. hdu1054Strategic Game(树形DP)

    链接 归属简单树形DP 挺简单的 跟第一道一样 就是我跑偏了题意..以为要覆盖点 纠结啊 推了N久 推不出啊 然后就郁闷了 打了局游戏 边想边打 实在想不出 看下题解 跑偏了 分两种情况D 方程见代码 ...

  8. Colored Sticks (字典树哈希+并查集+欧拉路)

    Time Limit: 5000MS   Memory Limit: 128000K Total Submissions: 27704   Accepted: 7336 Description You ...

  9. sqliteExpert软件使用(创建数据库和表)

    sqliteExpert是sqlite数据库的可视化操作软件,通过该软件可以进行可视化的创建数据库以及表,免去了复杂的建表语句.首先在下面地址下载该软件http://www.ddooo.com/sof ...

  10. zz-rtl8188eu的linux-usb-wifi调试及驱动编译150210

    //zz//####################################################################### zz-rtl8188eu的linux-usb ...