Buffon's Needle

아직 제출이 없습니다시간 제한4초메모리 제한1024 MB

문제

For millenia, people have been interested in approximating π\pi. One famous method is known as Buffon's Needle: drop a bunch of needles of length 11 on a coordiate plane with a vertical line drawn at each integer xx coordinate (so there are lines x=0x = 0, x=1x = 1, x=1x = -1, and so on). Each needle either intersects a vertical line, or lies entirely between two vertical lines. It turns out that, if the needles are dropped randomly, the fraction of needles that intersect a vertical line can be used to approximate π\pi! (The specific assumptions about exactly how the needles are dropped in the experiment are not important for this problem.)

In particular, let xx be the fraction of needles that intersect a vertical line. Then

π2x.\pi \approx \frac{2}{x}.

You are given the positions of NN needles (not necessarily random), and it is guaranteed that at least one of them intersects a vertical line. What is the corresponding approximation of π\pi, using the above formula?

입력

The first line of input contains a single integer NN (1N1041 \leq N \leq 10^4), the number of needles. NN lines follow.

The ii-th such line describes the ii-th needle. It contains four real numbers: x_i1,y_i1,x_i2,y_i2x\_{i1}, y\_{i1}, x\_{i2}, y\_{i2}. This means that the ii-th needle has one endpoint at (x_i1,y_i1)(x\_{i1}, y\_{i1}) in the plane and the other endpoint at (x_i2,y_i2)(x\_{i2}, y\_{i2}).

All real numbers in the input are given with exactly 66 digits after the decimal point and have absolute value at most 1010. Furthermore, it is guaranteed that no xx coordinates in the input are within 10610^{-6} of an integer.

Since all the needles are of length 11, for each ii it is guaranteed that

(x_i1x_i2)2+(y_i1y_i2)21<103.|(x\_{i1} - x\_{i2})^2 + (y\_{i1} - y\_{i2})^2 - 1| < 10^{-3}.

출력

Output a single real number, the approximation of π\pi described above. Your answer is considered correct if its absolute or relative error is at most 10610^{-6}.

힌트

In the first sample, the first needle intersects a vertical line (x=1x = 1), but the second doesn't. So the fraction of needles that intersect vertical lines is 1/21/2 and the corresponding approximation of π\pi is 44.

In the second sample, both the needles intersect vertical lines (x=1x = 1 and x=0x = 0), so the fraction of needles that intersect vertical lines is 11 and the corresponding approximation of π\pi is 22.