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. TCP之超时和重传

    RTT:往返时间:  RTO:Retransmission Timeout即超时重传时间: 关键点在于:超时和重传间隔的策略,即怎样确定超时间隔和重传间隔: TCP中的四个定时器:2MSL定时器:重传 ...

  2. Oracle中的单引号问题

    SELECT '<a href="javascript:void(0)" onclick="openWyl('''||a.aac001 FROM ac01 a; S ...

  3. 关于QuartusII对ram块的综合

    之前在看Altera的官方教程上就有说明,如果我们定义一个reg [`word_w]user_ram[`word_d]  ; QuartusII会自动综合成为一个ram—— 当然有一些前提:(后续补充 ...

  4. javascript入门视频第一天 小案例制作 零基础开始学习javascript

    JavaScript 是我们网页设计师必备的技能之一.我们主要用javascript来写的是网页特效.我们从零基础开始学习javascript入门. 但是,好的同学刚开始不知道怎么学习,接触js,因此 ...

  5. [蘑菇街] 搜索、算法团队招募牛人啦-年底了走过路过不要错过 - V2EX

    [蘑菇街] 搜索.算法团队招募牛人啦-年底了走过路过不要错过 - V2EX [蘑菇街] 搜索.算法团队招募牛人啦-年底了走过路过不要错过

  6. AsyncTask简单入门

    关系: java.lang.Object    ↳    android.os.AsyncTask<Params, Progress, Result> 概述: AsyncTask是Andr ...

  7. Ubuntu: 搭建tftp,nfs服务器

    Ubuntu12.04搭建tftp&nfs服务器 http://blog.163.com/thinki_cao/blog/static/83944875201411610467306/ 硬件环 ...

  8. C++变量(C++变量定义、变量赋值、命名规则)

    其实在前面的例子中已经多次用到了变量.在程序运行期间其值可以改变的量称为变量.一个变量应该有一个名字,并在内存中占据一定的存储单元,在该存储单元中存放变量的值.请注意区分变量名和变量值这两个不同的概念 ...

  9. 关于负数的isdigit()判断

    -->the start 今天写作业的时候突然想到,一直使用isdigit()方法来处理用户的输入选择是不是数字,但是如果用户输入的是负数呢,会不会导致bug? 然后我就试了一下,居然不报错.. ...

  10. oracle 表复制

    1. 复制表结构及其数据: create table table_name_new as select * from table_name_old 2. 只复制表结构: ; 或者 create tab ...