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. POJ3714+最近点对

    特判标记即可 #include<stdio.h> #include<string.h> #include<stdlib.h> #include<math.h& ...

  2. *[topcoder]HexagonalBoard

    http://community.topcoder.com/stat?c=problem_statement&pm=12784 真心觉得tc的div1 250不少好题,对我来说比较适合.这道题 ...

  3. Date简介

    Date类 在JDK1.0中,Date类是唯一的一个代表时间的类,但是由于Date类不便于实现国际化,所以从JDK1.1版本开始,推荐使用Calendar类进行时间和日期处理.这里简单介绍一下Date ...

  4. 关于方程x^2+y^2=p (p为素数)的解问题

    问题描述:对于方程,其中为素数,x,y为整数,且,输出符合条件的x,y. 分析:对于本方程,我们通过费马平方和定理知道,只有奇素数p满足这个条件时才有解. 那么当此方程有解时,解有几个呢?很明显不可能 ...

  5. Sublime Text主题下载、安装与配置

    从下面地址下载主题包,以下载第一个为例,解压缩并重命名为Theme – Flatland 备注:下载好的文件中  .sublime-theme后缀的表示界面主题(theme),.tmTheme表示颜色 ...

  6. 3 Financial Services Social Media Success Storie

    As financial services firms step-up their use of social media, we’ve been looking for some early suc ...

  7. BZOJ_3527_[ZJOI2014]_力_(FFT+卷积)

    描述 题面: http://wenku.baidu.com/link?url=D2ORnA9xjgSxa2GlYLB7gGiYgBcXsy-Aw0kVYTjTE-iYhH1s7h8xXGmnaMwl3 ...

  8. 定制属于自己的自动化安装的linux系统镜像

    使用软件和平台 1.基于平台:                  Vmware workstation 8.0 2.基于系统镜像:               rhel-server-5.8-i386 ...

  9. [Uva 11825] Hackers’ Crackdown

    Hackers’ Crackdown  Input: Standard Input Output: Standard Output   Miracle Corporations has a numbe ...

  10. c程序设计语言_习题1-9_将输入流复制到输出流,并将多个空格过滤成一个空格

    Write a program to copy its input to its output, replacing each string of one or more blanks by a si ...