402660: GYM100834 I Polycarp and Heat Exchangers

Memory Limit:512 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

I. Polycarp and Heat Exchangerstime limit per test2 secondsmemory limit per test512 megabytesinputstandard inputoutputstandard output

Polycarp does experiments again. He has N triangle heat exchangers on the field. Each i-th heat exchanger has input and output and their coefficients kini and kouti respectively. If two heat exchangers intersect (or first one touches second one), then thir inputs becamee molten together and their input coefficient became k, where , k1 and k2 are input coefficients of heat exchangers. Each point of field emits heat, heat comes out with specific speed. If this point is beneath some heat exchangers, it's value is multiplied by final value of their input coefficient and then it's multiplied by their output coefficients. Square of field with sides's length 1 emits 1 unit of heat. Polycarp wants to know value of heat per second, which emits all heat exchangers.

Input

The first line contains N, 1 ≤ N ≤ 10. N lines follow, each containing x1i, y1i, x2i, y2i, x3i, y3i, kini, kouti — coordinates of vertexes i-th heat exchanger, input and output coefficients. All numbers are separated by space, coordinates are integers, which are lesser than 101 and greater than  - 101, 0.1 ≤ kini, kouti ≤ 2.0. Triangles are not degenerate.

Output

Output summary value of heat per second, which emits all heat exchangers. You may assume that answers is coparated with the precision of 10 - 4.

ExamplesInput
2
0 0 4 4 8 0 1 1
1 3 7 3 4 -1 1 1
Output
9.51785700
Input
2
-100 100 -100 -100 75 -100 0.5 2
100 100 100 -100 -75 -100 0.5 2
Output
17500.00000000

加入题单

算法标签: