eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків

Archery

Last summer you were watching all the matches in the 2012 Olympics in London. One of the interesting sports is archery (it's the game of propelling arrows with the use of a bow to hit a target), but in this problem we are dealing with a new type of archery. In this new type of archery, the player has arrows that can penetrate any target and can go to infinity (the same arrow may hit more than one target), and there will be a lot of targets around the player everywhere, and the targets may intersect and/or overlap with each others. From the top view you can model the targets as line segments and the player as a point at the origin (point \textbf{(0,0)}is the origin), also there will be no target which intersects with the player's position. You are really interested to calculate the expected number of targets this player can penetrate using one arrow, if he will shoot his arrow in a random direction (there are innite number of different directions, and each direction has the same probability to be used for the random shoot). For example, the following figure explains the first sample test case, where the player is at the origin, and there are two targets \textbf{T_1} with end points \textbf{(1,5)} and \textbf{(3,3)}, and \textbf{T_2} with end points \textbf{(3,5)} and \textbf{(6,2)}, you can notice that there is a region where the player can shoot an arrow and penetrate the two targets, and there are two regions where he can penetrate only one target, and the last region he will not penetrate any target. \includegraphics{https://static.e-olymp.com/content/04/043dad8295b5af3731cf615346d5e8bffead096b.jpg} Note that a target can be hit at any point between its \textbf{2} end points (inclusive). \InputFile Your program will be tested on one or more test cases. The first line of the input will be a single integer \textbf{T}, the number of test cases (\textbf{1} ≤ \textbf{T} ≤ \textbf{100}). Followed by the test cases, each test case starts with a line containing one integer \textbf{N} (\textbf{1} ≤ \textbf{N} ≤ \textbf{100}) representing the number of targets in the game. Followed by \textbf{N} lines, the ith line contains \textbf{4} integers separated by a single space \textbf{X_1 Y_1 X_2 Y_2} (\textbf{-100} ≤ \textbf{X_1}, \textbf{Y_1}, \textbf{X_2}, \textbf{Y_2} ≤ \textbf{100}) representing the ith target end points \textbf{(X_1,Y_1) }and \textbf{(X_2,Y_2)}. \OutputFile For each test case, print on a single line, a single number representing the expected number of targets the player can penetrate using one arrow, rounded to five decimal places.
Ліміт часу 1 секунда
Ліміт використання пам'яті 64 MiB
Вхідні дані #1
2
2
1 5 3 3
3 5 6 2
8
3 0 0 3
0 3 -3 0
-3 0 0 -3
0 -3 3 0
3 3 -3 3
-3 3 -3 -3
-3 -3 3 -3
3 -3 3 3
Вихідні дані #1
0.20636
2.00000
Джерело Arab Collegiate Programming Contest 2012