Problem Description

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

题意:每个样例给出n,然后n个坐标,求这些点能组成多少个锐角三角形

思路:只要知道锐角三角形三边的关系a^2+b^2>c^2即可

#include <stdio.h>
#include <string.h>
#include <math.h> int main()
{
double a[2][105],x,y,z;
int i,j,k,ans,n,t,flag1,flag2,flag3;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
for(i = 0;i<n;i++)
scanf("%lf%lf",&a[0][i],&a[1][i]);
ans = 0;
for(i = 0;i<n-2;i++)
{
for(j = i+1;j<n-1;j++)
{
for(k = j+1;k<n;k++)
{
flag1 = flag2 = flag3 = 0;
x = sqrt((a[0][i]-a[0][j])*(a[0][i]-a[0][j])+(a[1][i]-a[1][j])*(a[1][i]-a[1][j]));
y = sqrt((a[0][i]-a[0][k])*(a[0][i]-a[0][k])+(a[1][i]-a[1][k])*(a[1][i]-a[1][k]));
z = sqrt((a[0][k]-a[0][j])*(a[0][k]-a[0][j])+(a[1][k]-a[1][j])*(a[1][k]-a[1][j]));
if(x*x+y*y>z*z)
flag1 = 1;
if(y*y+z*z>x*x)
flag2 = 1;
if(x*x+z*z>y*y)
flag3 = 1;
if(flag1 && flag2 && flag3)
ans++;
}
}
}
printf("%d\n",ans);
} return 0;
}

FZOJ2110: Star的更多相关文章

  1. 简历求职:STAR法则

    做了近2年的大学生就业辅导工作,也接触了很多即将走出校园的大学生,做个总结与大家分享,同时也是对自己的一个总结. 最近刚听说STAR法则,这也是一直我们给学生的指导思想,百度了一下: STAR法则,即 ...

  2. 关于转录组比对STAR软件使用

    参考文章:http://weibo.com/p/23041883f77c940102vbkd?sudaref=passport.weibo.com 软件连接:https://github.com/al ...

  3. 深入学习:Windows下Git入门教程(下)

    声明:由于本人对于Git的学习还处于摸索阶段,对有些概念的理解或许只是我断章取义,有曲解误导的地方还请见谅指正! 一.分支 1.1分支的概念. 对于的分支的理解,我们可以用模块化这个词来解释:在日常工 ...

  4. 从零开始学ios开发(十二):Table Views(上)

    这次学习的控件非常重要且非常强大,是ios应用中使用率非常高的一个控件,可以说几乎每个app都会使用到它,它就是功能异常强大的Table Views.可以打开你的iphone中的phone.Messa ...

  5. node初步一:HTTP请求

    一. 创建pathtest.js文件 var http= require('http' ); var url= require('url' ); function start (){ function ...

  6. STL 查找vector容器中的指定对象:find()与find_if()算法

    1 从vector容器中查找指定对象:find()算法 STL的通用算法find()和find_if()可以查找指定对象,参数1,即首iterator指着开始的位置,参数2,即次iterator指着停 ...

  7. 技术趋势:React vs Vue vs Angular

    React.Vue 和 Angular 这两年发展状况如何?2019 年哪个技术最值得学习? 前几天 Medium 上有一位作者发表了一篇关于 React.Vue 和 Angular 技术趋势的文章( ...

  8. DART: a fast and accurate RNA-seq mapper with a partitioning strategy DART:使用分区策略的快速准确的RNA-seq映射器

    DART: a fast and accurate RNA-seq mapper with a partitioning strategyDART:使用分区策略的快速准确的RNA-seq映射器 Abs ...

  9. 关于Star UML

    为什么是使用Star UML而不是Visio 2013呢? 以前本人在大学期间使用的Visio 2013来绘制UML的,最近一个星期因为在阅读源码,所以有多学了一门UML绘制工具—Star UML,下 ...

随机推荐

  1. 64位系统/32位系统下/8位CPU的数据宽度

    不同的编译器根据不同的 64 位模型有所不同. 比如 Visual C++,从第一个支持 64 位的版本起,一直就是使用 LLP64 内存模型,也就是说,编译出的代码除了 long 和指针是 64 位 ...

  2. 自己新建Xib 和.h .m文件关联

    代理中注意点 1.新建MainViewController.h 和 MainViewController.m文件: 新建Main.xib文件: 2.拖View到Main.xib中: 3.点击File’ ...

  3. 百度SiteApp构建网站APP

    现在很多个人网站和企业网站都是传统的Web方式,有没有想过个人/企业网站也能做成APP应用对外宣传呢?专门找人去开发Android和IOS上的APP又太贵,为了赶上移动互联网时髦,我以个人网站试做了一 ...

  4. Android百度地图之显示地图

    添加地图显示 一.在百度官网下载相关的SDK (网址:http://developer.baidu.com/map/sdkandev-download.htm) 解压下载好的BaiduMap_Andr ...

  5. Ajax以及类似百度搜索框的demo

    public class Ajax01 extends HttpServlet{ @Override protected void service(HttpServletRequest request ...

  6. svn笔记

    安装部署 1.yum install subversion   2.创建svn版本库目录 mkdir -p /svn   3.创建版本库 svnadmin create /svn/fengchao/ ...

  7. 树莓派常用Linux命令

    转自小五义 1.ls命令:列出文件目录的常用命令,主要参数见下表. -a 列出目录下的所有文件,包括以.开头的隐含文件. -b 把文件名中不可输出的字符用反斜杠加字符编号(就象在C语言里一样)的形式列 ...

  8. Calling 64-bit assembly language functions lodged inside the Delphi source code

    Code: http://www.atelierweb.com/calling-64-bit-assembly-language-functions-lodged-inside-the-delphi- ...

  9. assert使用

    assert宏的原型定义在<assert.h>中,其作用是如果它的条件返回错误,则终止程序执行,原型定义: #include <assert.h> void assert( i ...

  10. python模块学习---HTMLParser(解析HTML文档元素)

    HTMLParser是Python自带的模块,使用简单,能够很容易的实现HTML文件的分析. 本文主要简单讲一下HTMLParser的用法. 使用时需要定义一个从类HTMLParser继承的类,重定义 ...