IoU

TimeLimit:1000MS  MemoryLimit:32MB
64-bit integer IO format:%I64d
未提交 | 登录后收藏
Problem Description

Xzz need to calculate Intersection over Union(IoU) of two rectangles, can you help him?

rectangle (x, y, w, h) means a rectangle MNPQ, M(x,y), N(x, y+h), P(x+w, y+h), Q(x+w, y).

IoU = Area of overlap / Area of union.

Input

First line of the input file contains an integer T(0 < T <= 100) that indicates how many cases of inputs are there.

The description of each case is given below:

The first line of each input set contains integer x1, y1, w1, h1.

The second line of each input set contains integer x2, y2, w2, h2.

0 ≤ x, y, w, h ≤ 100000

Output

The description of output for each test case is given below:

The first line of the output for each test case contains number k- the IoU of two rectangles.

Output should be rounded to 2 digits after decimal point.

SampleInput
2
1 1 1 1
1 1 2 2
1 1 2 1
1 1 1 2
SampleOutput
0.25
0.33
Submit
题目统计信息详细
总AC数40
通过人数30
尝试人数32
总提交量79
AC率37.97%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: