码迷,mamicode.com
首页 > 其他好文 > 详细

寒假集训.Intersection

时间:2015-02-04 16:43:56      阅读:116      评论:0      收藏:0      [点我收藏+]

标签:c++   oj   acm   几何   

Intersection
Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu

Description

技术分享


 Intersection 

You are to write a program that has to decide whether a given line segment intersects a given rectangle.

An example:

 line: 		 start point: 		 (4,9)

end point: (11,2)

rectangle: left-top: (1,5)

right-bottom: (7,1)

 技术分享
Figure: Line segment does not intersect rectangle

The line is said to intersect the rectangle if the line and the rectangle have at least one point in common. The rectangle consists of four straight lines and the area in between. Although all input values are integer numbers, valid intersection points do not have to lay on the integer grid.

Input

The input consists of n test cases. The first line of the input file contains the number n. Each following line contains one test case of the format:

技术分享

where (xstartystart) is the start and (xendyend) the end point of the line and (xleftytop) the top left and (xrightybottom) the bottom right corner of the rectangle. The eight numbers are separated by a blank. The terms 技术分享 and 技术分享 do not imply any ordering of coordinates.

Output

For each test case in the input file, the output file should contain a line consisting either of the letter "T" if the line segment intersects the rectangle or the letter "F" if the line segment does not intersect the rectangle.

Sample Input

1
4 9 11 2 1 5 7 1

Sample Output

F

先判断线段所在直线是否穿过某一矩形对角线(1),若不穿过,则线段与矩形必不相交,若穿过在判断线段两个端点是否在矩形的一侧,因为有了条件(1)则不在一侧时必与矩形相交,否则不相交。

寒假集训.Intersection

标签:c++   oj   acm   几何   

原文地址:http://blog.csdn.net/a576699534/article/details/43486465

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!