ZOJ Problem Set - 3923
Fujiwara no Mokou was formerly an ordinary human, but she became an immortal being after drinking the Hourai Elixir about 1300 years ago. She has some sort of control over fire.
One day, Mokou was on the way home after cutting bamboo. Suddenly it began to rain. As a manipulator of fire, Mokou dislikes rains. So she ran to her home as quickly as possible.
We can regard Mokou as a cylinder. The path can be simplified as a line. Mokou started from (0, 0, 0) and her home is at (x0, 0, 0). It is supposed that the rain is continuous and its density is 1. The rain will be absorbed immediately when it touches the surface of the cylinder or the ground. You need to measure how much weight of rain was absorbed by Mokou during her way to home in the rain.
There are multiple cases. The first line of the input contains an integer T (1 ≤ T ≤ 200) which indicates the number of cases. For each test case:
For each case, output the total weight of rain which was absorbed by Mokou. Absolute or relative error no more than 1E-6 will be accepted.
2 1 1 1 1 0 0 -1 2 3 3 3 2 3 -3
Author: ZHAO, Yueqi
Source: ZOJ Monthly, February 2016