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. ThinkPHP - 每个操作都检测用户是否登录

    TP提供了一个自动执行的函数_initialize(), 你创建一个公共控制器CommonAction.class.php文件. 定义了此方法,不能存在构造方法__construct() <?p ...

  2. 在storyboard中设置控件的layerbordercolor

    在SB中控件可以在SB中直接利用kvc 设置一些属性值,不如layerwidth等 但是不能更改和颜色有关的属性因为layerbordercolor是CGColor.通过为CALayer增加属性可以实 ...

  3. WebView之2

    首先需要添加权限: <uses-permission android:name="android.permission.INTERNET"/> MainActivity ...

  4. System.IO

                 I/O       1.文件操作:File (1)void AppendAllText(string path, string contents) (2)bool Exist ...

  5. 使用apache benchmark(ab) 测试报错汇总

    1.socket: Too many open files (24) 解决方法: [root@zabbix ~]# ulimit -a core file size (blocks, -c) 0 da ...

  6. js window.onload事件

    1.最简单的调用方式 直接写到html的body标签里面,如: ? 1 2 3 4     <html>       <body onload="func()"& ...

  7. POJ 1142 质因数分解

    只要很朴素的分解就可以了,数据量不大 #include <stdio.h> #include <string.h> #include <stdlib.h> #inc ...

  8. mul16

    设计思想:乘法运算本身就可以看做是一个移位相加的过程               1 1 0 1 0     = 26*              1 0 1 1 1    = 23          ...

  9. php启用gzip压缩

    GZIP(GNU-ZIP)是一种压缩技术.经过GZIP压缩后页面大小可以变为原来的30%甚至更小.这样用户浏览的时候就会感觉很爽很愉快! 要实现GZIP压缩页面需要浏览器和服务器共同支持,实际上就是服 ...

  10. Python字典处理技巧

    从字典中取值(不想由于搜索的键不存在而异常) 解决方法: 使用字典的get方法 (get方法只读取字典的值而不会去修改字典) d={'key':'value'} print d.get('key',' ...