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

本来想用算夹角的函数的,还特意去找了一下模板

后来应该是因为精度WA了

才发现其实只用判断一下边之间的关系就可以判断是不是锐角三角形了

emmm题目的意思还要学会转换

判断锐角三角形:

A^2 + B^2 < C^2 就是锐角三角形

算夹角的模板:【没有精度判断】

double getAngle(Point p1, Point p2, Point p3)
{
double angle = 0.0;
Point va, vb;
va.x = p2.x - p1.x;
va.y = p2.y - p1.y;
vb.x = p3.x - p1.x;
vb.y = p3.y - p1.y; double productValue = va.x * vb.x + va.y * vb.y;
double vaVal = sqrt(va.x * va.x + va.y * va.y);
double vbVal = sqrt(vb.x * vb.x + vb.y * vb.y);
double cosVal = productValue / (vaVal * vbVal); if(cosVal < -1 && cosVal > -2){
cosVal = -1;
}
else if(cosVal > 1 && cosVal < 2){
cosVal = 1;
} angle = acos(cosVal) * 180 / PI;
return angle;
}
#include <iostream>
#include <algorithm>
#include <cstring> #include <cstdio> #include <cmath> using namespace std;
#define PI 3.1415926
#define EPS 1.0e-6 struct Point {
Point(){}
Point(double x, double y):x(x), y(y){}
double x,y; };
struct Line{
Point st, ed;
}; double getAngle(Point p1, Point p2, Point p3)
{
double angle = 0.0;
Point va, vb;
va.x = p2.x - p1.x;
va.y = p2.y - p1.y;
vb.x = p3.x - p1.x;
vb.y = p3.y - p1.y; double productValue = va.x * vb.x + va.y * vb.y;
double vaVal = sqrt(va.x * va.x + va.y * va.y);
double vbVal = sqrt(vb.x * vb.x + vb.y * vb.y);
double cosVal = productValue / (vaVal * vbVal); if(cosVal < -1 && cosVal > -2){
cosVal = -1;
}
else if(cosVal > 1 && cosVal < 2){
cosVal = 1;
} angle = acos(cosVal) * 180 / PI;
return angle;
} int dblcmp(double r) { if(fabs(r)<EPS) return 0; return r>0?1:-1; } double cross(Point p1, Point p2, Point p3, Point p4)
{
return (p2.x - p1.x) * (p4.y - p3.y) - (p2.y - p1.y) * (p4.x - p3.x);
} double area(Point p1, Point p2, Point p3)
{
return cross(p1, p2, p1, p3);
} double farea(Point p1, Point p2, Point p3)
{
return fabs(area(p1, p2, p3));
} bool meet(Point p1, Point p2, Point p3, Point p4)
{
return max(min(p1.x, p2.x), min(p3.x, p4.x)) <= min(max(p1.x, p2.x), max(p3.x, p4.x))
&& max(min(p1.y, p2.y), min(p3.y, p4.y)) <= min(max(p1.y, p2.y), max(p3.y, p4.y))
&& dblcmp(cross(p3, p2, p3, p4) * cross(p3, p4, p3, p1)) >= 0
&& dblcmp(cross(p1, p4, p1, p2) * cross(p1, p2, p1, p3)) >= 0;
} Point inter(Point p1, Point p2, Point p3, Point p4)
{
double k = farea(p1, p2, p3) / farea(p1, p2, p4);
return Point((p3.x + k * p4.x) / (1 + k), (p3.y + k * p4.y) / (1 + k));
} bool sharpTri(Point p1, Point p2, Point p3)
{
double edge[3];
edge[0] = (p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y);
edge[1] = (p1.x - p3.x) * (p1.x - p3.x) + (p1.y - p3.y) * (p1.y - p3.y);
edge[2] = (p2.x - p3.x) * (p2.x - p3.x) + (p2.y - p3.y) * (p2.y - p3.y); sort(edge, edge + 3);
if(edge[2] < edge[1] + edge[0] + EPS){
return true;
}
else return false;
} int n;
Point star[105]; int main() { int t;
cin>>t;
while(t--){
scanf("%d", &n);
for(int i = 0; i < n; i++){
scanf("%lf%lf", &star[i].x, &star[i].y);
}
int cnt = 0;
for(int i = 0; i < n - 2; i++){
for(int j = i + 1; j < n - 1; j++){
for(int k = j + 1; k < n; k++){
//cout<<getAngle(star[i], star[j], star[k])<<endl;
if(sharpTri(star[i], star[j], star[k])) cnt++;
}
}
}
cout<<cnt<<endl;
} return 0; }

FZU2110 Star【计算几何】的更多相关文章

  1. POJ 2420 A Star not a Tree? (计算几何-费马点)

    A Star not a Tree? Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3435   Accepted: 172 ...

  2. POJ 2069 Super Star(计算几何の最小球包含+模拟退火)

    Description During a voyage of the starship Hakodate-maru (see Problem 1406), researchers found stra ...

  3. [转] POJ计算几何

    转自:http://blog.csdn.net/tyger/article/details/4480029 计算几何题的特点与做题要领:1.大部分不会很难,少部分题目思路很巧妙2.做计算几何题目,模板 ...

  4. ACM计算几何题目推荐

    //第一期 计算几何题的特点与做题要领: 1.大部分不会很难,少部分题目思路很巧妙 2.做计算几何题目,模板很重要,模板必须高度可靠. 3.要注意代码的组织,因为计算几何的题目很容易上两百行代码,里面 ...

  5. 【Star CCM+实例】开发一个简单的计算流程.md

    流程开发在CAE过程中处于非常重要的地位. 主要的作用可能包括: 将一些经过验证的模型隐藏在流程中,提高仿真的可靠性 将流程封装成更友好的界面,降低软件的学习周期 流程开发实际上需要做非常多的工作,尤 ...

  6. github中的watch、star、fork的作用

    [转自:http://www.jianshu.com/p/6c366b53ea41] 在每个 github 项目的右上角,都有三个按钮,分别是 watch.star.fork,但是有些刚开始使用 gi ...

  7. [deviceone开发]-Star分享的几个示例

    一.简介 这个是star早期分享的几个示例,都非常实用,包括弹出的菜单,模拟支付密码输入等.初学者推荐.也可以直接使用.二.效果图 三.相关下载 https://github.com/do-proje ...

  8. 时隔一年再读到the star

    The Star Arthur C. Clarke It is three thousand light-years to the Vatican. Once, I believed that spa ...

  9. Github上的Watch和 Star的区别

    Github 推出了新的 Notification 系统,更改了原有的 Watch 机制,为代码库增加了 Star 操作.Notification 将接收 Watching 代码库的动态,包括:* I ...

随机推荐

  1. Js页面刷新前提示-jquery页面刷新事件

    //原理很简单,就是在body的onbeforeunload事件绑定函数,代码如下: document.body.onbeforeunload = function (event) { var c = ...

  2. 定时器Enable Disable控制

    问题:定时器如何控制它一会可用一会不可用,根据某个业务需求,比如:一个控制台程序扫描表中某个条件的数据,处理数据,控制台分布式部署,当主机宕机后,从机扫描定时器需要可用,当主机复活后,从机的扫描定时器 ...

  3. WPF送走控件的focus方法

    我们可以调用Focus()方法,让WPF控件获得焦点, 那我现在不想要焦点了, 如何把这个包袱抛出去? 可以,  恩, 没有Unfocus(), 但下面的方法也许可行(把焦点抛给另一个不知道的控件): ...

  4. 【AI】Win10-Tensorflow

    一.安装 第一步:先安装anaconda3第二步:pip install --upgrade --ignore-installed tensorflow或者:pip install tensorflo ...

  5. 【代码审计】CLTPHP_v5.5.3后台任意文件删除漏洞分析

      0x00 环境准备 CLTPHP官网:http://www.cltphp.com 网站源码版本:CLTPHP内容管理系统5.5.3版本 程序源码下载:https://gitee.com/chich ...

  6. RF--执行案例时动态传入参数方法

    通过在运行界面的设定-v 参数值来动态传入:

  7. 【RF库Collections测试】List Should Contain Value

    Name:List Should Contain ValueSource:Collections <test library>Arguments:[ list_ | value | msg ...

  8. EhCache初体验

    一.简介 EhCache 是一个纯Java的进程内缓存框架,具有快速.精干等特点.Ehcache是一种广泛使用的开源Java分布式缓存.主要面向通用缓存,Java EE和轻量级容器.它具有内存和磁盘存 ...

  9. 关于 Handler 与 opener

    我们可以使用 urllib.request.Request() 构造请求对象,但是对于一些更高级的操作,比如 Cookies 处理.代理设置 .身份验证等等,Request() 是处理不了的这时就需要 ...

  10. 第五篇:Hadoop流

    前言 Hadoop流提供了一个API,允许用户使用任何脚本语言编写Map函数或Reduce函数. 本文对此知识点进行介绍. Hadoop流的工作原理 在以前的例子中,Map和Reduce工作都是由类来 ...