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. SQL SERVER发布与订阅

    一.配置分发 1.配置分发服务器,注:配置发布与订阅,连接SQLSERVER必须用服务器名登录 2.配置分发 3.选择分发服务器 4.选择快照文件夹 5.设置此文件夹的读写权限为everyone 6. ...

  2. c#POST请求php接口

    POST请求php接口 /// <summary> /// 指定Post地址使用Get 方式获取全部字符串 /// </summary> /// <param name= ...

  3. Spring IOC-ContextLoaderListener

    [spring version : 4.1.6.RELEASE] 使用spring的项目中,一般都会在web.xml中配置ContextLoaderListener,它就是spring ioc 的入口 ...

  4. Nexus5 电信3G保留数据和Root升级Android 6.0

    前提: A 备份手机重要数据,安全第一 B 进入twrp recovery 备份EFS,建议最好拷贝到电脑上(如果没有twrp,则需要先刷twrp,具体指令请看下面步骤第10条) C 因为Androi ...

  5. express不是内部或外部命令,也不是可运行的程序或批处理文件

    如上安装了express以后,仍然报如下错误:express不是内部或外部命令,也不是可运行的程序或批处理文件 原因是版本问题:当前版本是4.0.0,改成3.5.0即可运行. npm install ...

  6. 【代码审计】iCMS_v7.0.7 admincp.app.php页面存在SQL注入漏洞分析

      0x00 环境准备 iCMS官网:https://www.icmsdev.com 网站源码版本:iCMS-v7.0.7 程序源码下载:https://www.icmsdev.com/downloa ...

  7. VS2015编译提示无法运行“rc.exe”

    使用VSx64命令行编译项目,提示无法运行“rc.exe” 想办法搜索rc.exe和rcdll.dll这两个文件,然后拷贝到C:\Program Files (x86)\Microsoft Visua ...

  8. Android的Fragment中onActivityResult不被调用

    1.检查该Fragment所属的Activity中,是否重写了onActivityResult方法. 2.检查Fragment中的startActivityForResult的调用方式. 请确保不要使 ...

  9. React Native(九)——实现仿微信朋友圈发表动态功能

    好像很久都没写博客了,罪过罪过~ 许是因为刚接触App有点生疏不得窍门吧,这个月还没有更新过文章.小个把月下来,还是觉得应该边学边总结,这样才能像大神靠近(最近刚接触同业的大牛级人物,还是从中学到了很 ...

  10. WIN32编程经验总结

    一 窗口和消息 1. 前缀: 2 WPARAM和LPARAM的意义在Windows是一种16位系统时,WndProc的第三个参数被定义为WORD,是一个16位的无符号整数,而第四个参数被定义为一个LO ...