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. golang-defer坑的本质

    https://blog.csdn.net/hittata/article/details/77836435

  2. 网易 2016 实习研发project师 3道 编程题

    1 比較重量 给定两颗钻石的编号g1,g2,编号从1開始.同一时候给定关系数组vector,当中元素为一些二元组.第一个元素为一次比較中较重的钻石的编号,第二个元素为较轻的钻石的编号.最后给定之前的比 ...

  3. 有人在群里问mysql如何选择性更新部分条件的问题

    有人在群里问这个问题 update xt_kh set zhye=zhye+1,hzyj=hzyj+1 where dlgh='kiss0451' and hzms=1 如果这样写 hzms不等于1的 ...

  4. 统计js数组中奇数元素的个数

    如何统计一个JS数组中奇数元素的个数呢? 这是群友提出的一个问题,大部分群友给出的是遍历 然后对2取模,得到最终结果. 这样的写法是最容易想得到的,那么有没有其他思路呢? 这里我提供另外一种思路,我们 ...

  5. mysql 字符串转数据丢失精度,mysql转换丢失精度,mysql CAST 丢失精度

    mysql 字符串转数据丢失精度,mysql转换丢失精度,mysql CAST 丢失精度 =============================== ©Copyright 蕃薯耀 2017年9月1 ...

  6. java-使用SImpleDateFormat格式化时间输出

    之前有篇博客是使用NSDateFormatter来对时间进行格式化输出,但使用起来有点繁琐,今天介绍下最近刚刚使用的SimpleDateFormat. public class SimpleDateF ...

  7. sqlite3常用指令

    一.建立数据库 sqlite3.exe test.db 二.双击sqlite-3_6_16目录下的程序sqlite3.exe,即可运行 三.退出 .exit 或者 .quit 四.SQLite支持如下 ...

  8. flask路由中增加正则表达式

    #coding=utf-8 from flask import Flask from werkzeug.routing import BaseConverter class RegexConverte ...

  9. Windows命令行参数的知识(一)

    最近没事的时候,准备研究一下Windows命令行参数的知识,因为每次自己在操作电脑时总是效率太慢,如果能够了解Windows参数的一些知识,绝对能提高效率! 基本外部命令和内部命令 首先是基本的知识, ...

  10. PHP 连接oracle

    function connect_oracle(){ static $dbconn = false; if(!$dbconn){ $db_server = "127.0.0.1"; ...