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. bootstrap框架开发电子商城案例

    bootstrap框架开发电子商城案例 玛图 bootstrap 商城框架

  2. jQuery特效手风琴特效 手写手风琴网页特效

    今天写一个简单的手风琴效果,不用插件,利用强大的jQuery,写一个手风琴效果. 页面预览,请点击这里预览:  手风琴预览 案例分析: html结构 就是一个大盒子里面放着5个li,每个li的小小是2 ...

  3. android getDecorView()的作用

    decorView是window中的最顶层view,可以从window中通过getDecorView获取到decorView.通过decorView获取到程序显示的区域,包括标题栏,但不包括状态栏.间 ...

  4. 引用 移植Linux到s3c2410上

    引用 bsky 的 移植Linux到s3c2410上来源:http://www.embed.com.cn/downcenter/Article/Catalog12/4000.htm 移植Linux到s ...

  5. 网页制作之html基础学习2-标签

    一.html结构组成 <html> --开始标签 <head> 网页上的控制信息 <title>页面标题</title> </head> & ...

  6. 极光IM使用教程-极光推送

    链接地址:http://jingyan.baidu.com/article/a948d65178a6ea0a2ccd2e7e.html 极光IM使用教程,如果您的 App 需要同时集成 Push 功能 ...

  7. C++自增和自减运算符(--和++)

    在C和C++中,常在表达式中使用自增(++)和自减(--)运算符,他们的作用是使变量的值增1或减1,如:++i(在使用i之前,先使i的值加1,如果i的原值为3,则执行j=++i后,j的值为4)--i ...

  8. C++常变量

    在定义变量时,如果加上关键字const,则变量的值在程序运行期间不能改变,这种变量称为常变量(constant variable).例如:    const int a=3;  //用const来声明 ...

  9. Android之ksoap2-android详解与调用天气预报Webservice完整实例

    Google为Android平台开发Web Service客户端提供了ksoap2-android项目,在这个网址下载开发包http://code.google.com/p/ksoap2-androi ...

  10. Qt 富文本处理(QTextDocument和QTextBlock和QTextFrame和QTextTable和QTextList和QTextDocument)

    最近使用 Qt 做一个离线博客编辑器,因而用到了 Qt 的富文本处理.参考 Qt 的文档,记录下 Qt 的富文本处理的相关技术.文档地址是 http://doc.qt.nokia.com/4.7/ri ...