寒假集训.Intersection
2015-02-04 14:59
267 查看
IntersectionTime Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %lluSubmit StatusDescription
You are to write a program that has to decide whether a given line segment intersects a given rectangle.
Intersection |
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 rectangleThe 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 (xstart, ystart) is the start and (xend, yend) the end point of the line and (xleft, ytop) the top left and (xright, ybottom) 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)则不在一侧时必与矩形相交,否则不相交。
相关文章推荐
- 寒假集训附加题目题解报告(7)——"数学好奇心"
- (吐槽)寒假集训总结
- 寒假集训个人赛 D
- 寒假集训第一天--结构体训练
- 1.26寒假集训(并查集三连←.←)-4
- 寒假集训 Day 7 H题 UVALive - 3902 Network 网络
- 寒假▪福州集训 Day 3
- 寒假▪福州集训 Day5
- SDUT_2015寒假集训_结构体练习_A-Milk
- SDUT14级寒假集训-找女朋友- 快排
- SDUT_2015寒假集训_动规递推_B-超级楼梯
- SDUT_2015寒假集训_BFS&DFS_A-数据结构实验图论一:基于邻接矩阵的广度优先搜索遍历
- 寒假集训2 B hdu 5272 关于二进制
- JEECG寒假集训班开始报名啦!
- (寒假集训) 卡片(离散化)
- 寒假集训day7
- 寒假集训作业(3)——栈与队列
- 寒假集训个人赛 E
- 2013秋13级预备队集训练习4 --D - How Many Points of Intersection?
- 寒假集训之树状数组