eolymp
bolt
Try our new interface for solving problems
Problems

Mixing liquids

Mixing liquids

Drinking tea and other liquids (purely for the sake of conspiracy) is a vital part of the sittings of the Secret Committee. Hot tea is diluted with cold milk. Of course, everyone wants his tea to reach the perfect temperature as fast as possible. The temperature of the mixture is measured according to the exponential law: \includegraphics{https://static.e-olymp.com/content/65/656a7a6789c20f278a74d48b372c3356d1f0f14a.jpg} , where \textbf{T(t)} ―is the temperature at the moment of time \textbf{t}, \textbf{T_1} ― temperature of the mixture at the initial moment, \textbf{T_0} ― ambient temperature, \textbf{k} ― a certain static coefficient. When two liquids are mixed with the masses \textbf{m_1} and \textbf{m_2} and temperatures \textbf{T_1} and \textbf{T_2} respectively the result is a mixture with the temperature \includegraphics{https://static.e-olymp.com/content/90/9085fc82da9209f632ee4c6f0490eae361c7ee40.jpg} Let us consider that all liquids at the tea party have the same specific thermal capacity. The temperature of the first liquid begins to change according to the exponential law straight away, and at any moment of time we can mix it instantly with the second liquid, which has a stable temperature \textbf{T_2}, after which the temperature of the resulting liquid begins to change according to the same law with the same coefficient \textbf{k} and new temperature \textbf{T_1^\{′\}} calculated from the formula of temperatures of mixed liquids. We must calculate the minimal time necessary to achieve the desired temperature of the resulting mixture. \InputFile The first line of the input file must contain an integer \textbf{N} ― the number of tests. Each line of the following \textbf{N} lines contains seven integers \textbf{T_0}, \textbf{T_1}, \textbf{T_2}, \textbf{m_1}, \textbf{m_2}, \textbf{T_opt}, \textbf{k}. \textbf{T_0}, \textbf{T_1}, \textbf{T_2}, \textbf{T_opt} are the temperatures of the ambience, of the first and second liquids and the desired temperature, (\textbf{--273} < \textbf{T_0}, \textbf{T_1},\textbf{T_2}, \textbf{T_opt} ≤ \textbf{1000}), \textbf{m_1} and \textbf{m_2} are the masses of the first and second liquids (\textbf{0} ≤ \textbf{m_1}, \textbf{m_2} ≤ \textbf{1000}, \textbf{m_1+m_2} > \textbf{0}), and \textbf{k} is the coefficient for the speed of temperature change (\textbf{1} ≤ \textbf{k} ≤ \textbf{1000}). \OutputFile Each of \textbf{N} lines according to the sequence of data in the input file must contain a single real number ― the minimal time necessary to achieve the desired temperature calculated with a relative or absolute error margin not exceeding \textbf{10^\{−8\}} or the message \textbf{Impossible}, if the desired temperature cannot be achieved.
Time limit 1 second
Memory limit 64 MiB
Input example #1
2
0 1 1 10 10 1 1
0 1 1 10 10 0 1
Output example #1
0
Impossible
Source XIII All-Siberian Programming Contest named after I.V.Pottosin, November 11, 2012