Inside Triangle

https://hihocoder.com/contest/hiho225/problem/1

时间限制:10000ms
单点时限:1000ms
内存限制:256MB

描述

Determine if a point is inside a 2D triangle.

输入

The first line contains an integer T denoting the number of test case. (1 <= T <= 10)

The following T lines each contain 8 integers, Px, Py, Ax, Ay, Bx, By, Cx, Cy. P denotes the point. ABC denotes the triangle. The coordinates are within [-1000000, 1000000].

输出

For each test case output YES or NO denoting if the point is inside the triangle. Note that the point is considered inside the triangle if the point is just on some side of the triangle.

样例输入
2
0 1 -1 0 1 0 0 2
0 0 0 1 1 0 1 1
样例输出
YES
NO 用叉积判断是否同正负即可
 #include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<cstdio>
using namespace std; struct Point{
long long x,y;
}; long long Cross(Point P,Point A,Point B){
return (A.x-P.x)*(B.y-P.y)-(A.y-P.y)*(B.x-P.x);
} int main(){
int T;
scanf("%d",&T);
Point P,A,B,C;
while(T--){
scanf("%lld %lld %lld %lld %lld %lld %lld %lld",&P.x,&P.y,&A.x,&A.y,&B.x,&B.y,&C.x,&C.y);
long long ans1=Cross(A,B,P);
long long ans2=Cross(B,C,P);
long long ans3=Cross(C,A,P);
if((ans1<=&&ans2<=&&ans3<=)||(ans1>=&&ans2>=&ans3>=)){
puts("YES");
}
else{
puts("NO");
}
} }

Inside Triangle的更多相关文章

  1. hdu 1392凸包周长

    //用的自己的计算几何模板,不过比较慢嘿嘿 //要注意只有一个点和两个点 //Computational Geometry //by kevin_samuel(fenice) Soochow Univ ...

  2. C++ 凸包生成算法

    由于我的极差记忆力,我打算把这个破玩意先记下来.因为以后会有改动(Delaunay三角网生成算法),我不想把一个好的东西改坏了... 好吧-- 凸包生成算法,: 1.先在指定的宽(width)高(he ...

  3. 关于APIT定位算法的讨论

    关于APIT定位算法的讨论 [摘要]   无线传感器网络节点定位机制的研究中,基于距离无关的定位技术得到快速发展,其中基于重叠区域的APIT定位技术在实际环境中的定位精度高,被广泛研究和应用. [关键 ...

  4. Life of a triangle - NVIDIA's logical pipeline

    Home GameWorks Blog Life of a triangle - NVIDIA's logical pipeline   Life of a triangle - NVIDIA's l ...

  5. A trip through the Graphics Pipeline 2011_06_(Triangle) rasterization and setup

    Welcome back. This time we’re actually gonna see triangles being rasterized – finally! But before we ...

  6. 【POJ】2954 Triangle(pick定理)

    http://poj.org/problem?id=2954 表示我交了20+次... 为什么呢?因为多组数据我是这样判断的:da=sum{a[i].x+a[i].y},然后!da就表示没有数据了QA ...

  7. poj 2954 Triangle(Pick定理)

    链接:http://poj.org/problem?id=2954 Triangle Time Limit: 1000MS   Memory Limit: 65536K Total Submissio ...

  8. poj2954 Triangle

    地址:http://poj.org/problem?id=2954 题目: Triangle Time Limit: 1000MS   Memory Limit: 65536K Total Submi ...

  9. 【TOJ 3005】Triangle(判断点是否在三角形内+卡精度)

    描述 Given the coordinates of the vertices of a triangle,And a point. You just need to judge whether t ...

随机推荐

  1. IE, Firefox下,checkbox的钩钩一旦勾上,画面再刷新,钩钩还是勾上的解决方案

    如题,IE, Firefox下,checkbox的钩钩一旦勾上,画面再刷新,钩钩还是勾上的解决方案 <input type="checkbox"  />加上属性auto ...

  2. html如何设置打印样式?

    转自网络,忘记出处了. html/jsp/网页/打印相关/打印预览/js设置页眉页脚 <html> <head>    <title>打印相关</title& ...

  3. ubuntu 14.04 lamp 安装与配置

    一.安装apache 1.打开终端:Ctrl+Alt+T sudo apt-get update 2.通过apt-get方式安装Apache: sudo apt-get install apache2 ...

  4. eterm和easyfare的官网地址

    里面有eterm下载和eterm文档资料 运价软件easyfare和easyfare的文档. https://www.eterm.com.cn/caci/eterm/index-cn.jsp http ...

  5. Eclipse修改workspace目录的几种方式

    Eclipse是一款很强的Java IDE,我们在开始的时候,往往设定了默认的workspace,当用久在之后,我们可能要去更改一下workspace的位置.下面有几种方法可以更改workspace的 ...

  6. Python3 os.stat() 方法

    概述 os.stat() 方法用于在给定的路径上执行一个系统 stat 的调用.语法 stat()方法语法格式如下: os.stat(path) 参数 path -- 指定路径 返回值 stat 结构 ...

  7. Solr学习总结(六)solr的函数查询Function Queries

    摘要: 函数查询允许你使用一个或多个数字字段的真实值生成一个相关性分数,函数查询在standard,DisMax,eDisMax下都能使用. 查询函数可以是常量,字段或者其他函数的组合.使用函数可以影 ...

  8. Java操作Sqoop对象

    Windows下使用Eclipse工具操作Sqoop1.4.6对象 Sqoop是用来在关系型数据库与Hadoop之间进行数据的导入导出,Windows下使用Eclipse工具操作时,需要先搭建好Had ...

  9. VMware vCenter Server 6.5.0 U1g

    VMware vCenter Server 6.5.0 U1gName: VMware-VCSA-all-6.5.0-8024368.iso Release Date: 2018-03-20 Buil ...

  10. C#_Markov_心得感想

    来到实验室正好有一个月了,趁着端午假期稍微轻松一些,在大改程序体系之前,想将自己在这30天中工作之一Markov回顾一下,将从真实的写程序中学习到的知识.思想记录下来.希望能和大家积极讨论! 本文会以 ...