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. ThinkPHP中视图模型详解.

    很多TP的新手对于模型中的视图模型不甚了解,官方虽然有详细手册,但是对于初学者来说还是比较难以理解! 先简单说一下视图模型所能实现的功能,基本就是主表与副表之间各个字段的关联问题,实现多表关联查询,相 ...

  2. android activity在横竖屏切换的时候不重新调用onCreate方法

    在安卓系统中,横竖屏切换会默认重新调用onCreate等生命周期方法,如果此时有一些临时数据没有保存下来,很有可能会导致该数据丢失. 因此我们可以进行以下设置,来避免恒切换时重新调用onCreate方 ...

  3. android 业务需求: 先干掉自己, 在重启自己

    // 重启应用 public void restartApp() { Intent intent = new Intent(); // 参数1:包名,参数2:程序入口的activity intent. ...

  4. HTTP Header 入门详解

    什么是HTTP Headers HTTP是"Hypertext Transfer Protocol"的所写,整个www都在使用这种协定,几乎你在流览器里看到的大部分内容都是通过ht ...

  5. js设置radio选中

    在页面数据绑定时,经常会遇到给radio设置选中,以下是我写的js方法,经测试可以使用.欢迎拍砖 <html> <head> <script type="tex ...

  6. Linux使用wake_up_interruptible()唤醒注册到等待队列上的进程

    http://blog.sina.com.cn/s/blog_4770ef020101h48l.html     功能:唤醒注册到等待队列上的进程 原型:     #include     void ...

  7. packinfo-java的作用

    package-info.java 包的作用 1. 为标注在包上的Annotation提供便利 2. 声明包的私有类和常量 3. 提供包的整体注释说明   代码说明: package-info.jav ...

  8. 文件过滤驱动实现目录重定向(一)good

    文件过滤驱动拦截的IRP主要包括以下几个:IRP_MJ_CREATE,文件创建操作,文件的任何操作,都是从这里开始的.IRP_MJ_CLEANUP,文件的HANDLE句柄全部关闭会触发这个消息IRP_ ...

  9. 【PythonChallenge】Level 5

    题目主要找发声类似于Peak Hell的Python模块,查了一下手册pickle已经是最像的了.看了一下源代码,发现panner.p.如同发现了新大陆,拷贝内容.使用pickle解答.答案为chan ...

  10. Linux -- Ubuntu搭建java开发环境

    Steps 1 Check to see if your Ubuntu Linux operating system architecture is 32-bit or 64-bit, open up ...