2013省赛集训5 - Triangle
来源:互联网 发布:泛微协同软件 编辑:程序博客网 时间:2024/06/05 19:48
Triangle
Time Limit 1000ms
Memory Limit 65536K
description
Given the coordinates of the vertices of a triangle,And a point. You just need to judge whether the point is in the Triangle.
input
The input contains several test cases. For each test case, only line contains eight integer numbers , describing the coordinates of the triangle and the point. All the integer is in range of [-100 , 100]. The end of the input is indicated by a line containing eight zeros separated by spaces.
output
For each test case ,if the point is inside of the triangle,please output the string ”YES”,else output the string “NO”. You just need to follow the following examples.
sample_input
0 0 4 0 0 4 3 10 0 4 0 0 4 1 20 0 4 0 0 4 -1 -10 0 0 0 0 0 0 0
sample_output
NOYESNO
#include <iostream>#include <cstring>#include <algorithm>#include <cstdio>#include <cmath>using namespace std;int area(int x1,int y1,int x2,int y2,int x3,int y3){ return x1*y2+x2*y3+x3*y1-x2*y1-x3*y2-x1*y3;}//三角形有向面积的2倍,逆时针正,顺时针负int main(){ int x1,y1,x2,y2,x3,y3,x,y,s1,s2,s3,s; while(scanf("%d%d%d%d%d%d%d%d",&x1,&y1,&x2,&y2,&x3,&y3,&x,&y)!=EOF) { if(x1==0&&y1==0&&x2==0&&y2==0&&x3==0&&y3==0&&x==0&&y==0) break; x1+=100;y1+=100;x2+=100;y2+=100;x3+=100;y3+=100;x+=100;y+=100; s1=abs(area(x1,y1,x2,y2,x,y)); s2=abs(area(x1,y1,x3,y3,x,y)); s3=abs(area(x2,y2,x3,y3,x,y)); s=abs(area(x1,y1,x2,y2,x3,y3)); if((s1+s2+s3)==s&&s1&&s2&&s3) printf("YES\n"); else printf("NO\n"); } return 0;}
- 2013省赛集训5 - Triangle
- 2013秋13级预备队集训练习1 I - Triangle Wave
- NEFU2013省赛集训6
- ZJNU 省赛集训 清明节快乐~~
- 暑假集训 and 省赛总结
- 记2013暑期集训总结赛
- HDOJ2009暑期集训内部赛(5)
- 省队集训 water
- 省队集训DAY2
- 省队集训DAY3
- 省队集训DAY4
- 省队集训DAY5
- 省队集训DAY6
- 集训训练赛ZZU_1
- 集训训练赛day2
- 集训小记 5
- <8/5>集训日记
- 集训
- windows之启动过程(一)
- hdu 2072 单词数
- uva 670The dog task
- 第八周项目五----string类的扩充
- HOG参数简介及Hog特征维数的计算
- 2013省赛集训5 - Triangle
- EJB项目:角色授权(一)
- 极客技术专题【001期】:jQuery初学者入门
- InitInstance()函数
- 第五章 数组例题
- 现代通信网基础
- 将视频序列转换为图像序列
- 苹果手机外观设计的模板(psd)
- WCF 学习笔记心德体会(二)------Binding