#P4353. [CERC2015] Hovering Hornet

[CERC2015] Hovering Hornet

题目描述

You have managed to trap a hornet inside a box lying on the top of your dining table. Unfortunately, your playing dice is also trapped inside – you cannot retrieve it and continue your game of Monopoly without risking the hornet’s wrath. Instead, you pass your time calculating the expected number of spots on the dice visible to the hornet.

The hornet, the dice and the box are located in the standard three-dimensional coordinate system with the x coordinate growing eastwards, the y coordinate growing northwards and the z coordinate growing upwards. The surface of the table corresponds to the x-y plane.

The dice is a 1×1×1 cube, resting on the table with the center of the bottom side exactly in the origin. Hence,the coordinates of its two opposite cornersare (−0.5, −0.5, 0) and (0.5, 0.5, 1). The top side of the dice has 5 spots, the south side 1 spot, the east side 3 spots, the north side 6 spots, the west side 4 spots and the (invisible and irrelevant) bottom side 2 spots.

The box is a 5×5×5 cube also resting on the table with the dice in its interior. The box is specified by giving the coordinates of its bottom side – a 5×5 square.

Assume the hornet is hovering at a uniformly random point in the (continuous) space inside the box not occupied by the dice. Calculate the expected number of spots visible by the hornet. The dice is opaque and, hence, the hornet sees a spot only if the segment connecting the center of the spot and the location of the hornet does not intersect the interior of the dice.

输入格式

Input consists of 4 lines. The k-th line contains two floating-point numbers xk and yk (−5≤ xk, yk ≤5) –coordinates of the k-th corner of the bottom side of the box in the x-y plane. The coordinates are given in the counterclockwise direction and they describe a square with the side length of exactly 5.

The box fully contains the dice. The surfaces of the box and the dice do not intersect or touch except along the bottom sides.

输出格式

Output a single floating point number – the expected number of spots visible. The solution will be accepted if the absolute or the relative difference from the judges solution is less than 10610^{−6}.

题目大意

你把一只蜜蜂困在你餐桌上的一个盒子里。但是,你玩的骰子也被困在里面(你无法取回它)不过,你通过计算蜜蜂可以看到的骰子上的预期点数来消磨时间。

蜜蜂、骰子和盒子位于一个三维坐标系中,x-y轴如图

骰子是一个1×1×1的立方体,放在桌子上,底部的中心为原点。因此,其两个相对角的坐标为(−0.5, −0.5,0)和(0.5,0.5,1)。骰子顶部有5个点,南侧1个点,东侧3个点,北侧6个点,西侧4个点,底部2个点(不可见和不相关)。

盒子是一个5×5×5的立方体,也放在桌子上,里面有骰子。该框通过给出其底部的坐标(一个5×5的正方形)来指定。

假设蜜蜂在盒子内没有骰子的(连续)空间中的一个均匀随机点上盘旋。计算蜜蜂可以看到的点数的数量。骰子是不透明的,因此,只有当连接点数中心和蜜蜂位置的部分不与骰子内部相交时,蜜蜂才能看到斑点。

输入格式: 输入由4行组成。第k行包含两个浮点数xk和yk(−5<=xk,yk<=5)x-y平面中长方体底部第k个角的坐标。坐标以逆时针方向给出,它们描述了边长正好为5的正方形。 盒子和骰子的表面不相交或接触,除非放在底部。 输出格式: 输出一个数——预期可见点数 (样例如下)

-2.5 -1.5 
2.5 -1.5 
2.5 3.5 
-2.5 3.5
10.6854838710
3 0 
0 4 
-4 1 
-1 -3
10.1226478495

提示

Central Europe Regional Contest 2015 Problem H