「POJ2826」An Easy Problem?!

2014年4月14日4,7160

Description

It’s raining outside. Farmer Johnson’s bull Ben wants some rain to water his flowers. Ben nails two wooden boards on the wall of his barn. Shown in the pictures below, the two boards on the wall just look like two segments on the plane, as they have the same width.

Your mission is to calculate how much rain these two boards can collect.

Input

The first line contains the number of test cases.
Each test case consists of 8 integers not exceeding 10,000 by absolute value, x1y1x2y2x3y3x4y4. (x1y1), (x2y2) are the endpoints of one board, and (x3y3), (x4y4) are the endpoints of the other one.

Output

For each test case output a single line containing a real number with precision up to two decimal places – the amount of rain collected.

Sample Input

Sample Output

题解

此题好像非常有趣啊。。。

首先不能相交输出0

共线输出0

有一条线段平行x轴输出0

交点是一条线段的较高点输出0(其实这个直接算面积就行了)

还有俩线段开口不朝上,也就是长线段挡住了短的

精度要求不高。。

 

avatar
  Subscribe  
提醒