eolymp
bolt
Try our new interface for solving problems
Məsələlər

Optical Optimization

Optical Optimization

\includegraphics{https://static.e-olymp.com/content/84/8405e8f7e40249c2942b705a2629ecc534f3e148.jpg} The state of a \textit{linearly polarized laser beam} is represented by a pair of equal and opposite \textbf{2D} vectors (blue), parametrized by (\textbf{E}, \textbf{θ}), where \textbf{E} ≥ \textbf{0} is the beam's \textit{field strength} and \textbf{θ}, \textbf{0°} ≤ \textbf{θ} < \textbf{180°} is the beam's \textit{polarization angle}. This representation is illustrated on the right: A \textit{polarization filter} is represented by a line (red) through the origin, parametrized by its \textit{filter angle} \textbf{φ}, \textbf{0°} ≤ \textbf{φ} < \textbf{180°}. When a filter \textbf{φ} is applied to a beam (\textbf{E_a}, \textbf{θ_a}), a new beam (\textbf{E_b}, \textbf{θ_b}) emerges, and is evaluated by \textbf{E_b = E_b|cos(θ_a−φ)|}, \textbf{θ_b = φ}, \includegraphics{https://static.e-olymp.com/content/86/862da2e6e275013b92506674abf966bee909a4e5.jpg} i.e. the new beam loses strength, and takes on the angle of the filter. Geometrically, the opposing vectors represented by (E_a,θ_a) are "orthogonally projected" onto the line represented by φ, forming new opposing vectors represented by (E_b,θ_b), as shown on the left: \includegraphics{https://static.e-olymp.com/content/56/56c1601d8111478acadef0ea3e5b0b25847e57d6.jpg} Let us begin with a beam (\textbf{E_0}, \textbf{θ_0}) = (\textbf{1}, \textbf{0°}). If we apply a filter \textbf{φ_y = 90°}, then we would obtain a beam with \textbf{(E_y, θ_y) = (cos(90°), 90°) = (0, 90°)}, i.e. a beam with strength zero. \includegraphics{https://static.e-olymp.com/content/a6/a6025ba7b087bcfbe089266f38593fb261e33887.jpg} Suppose we have another filter ξ_x = 45°, and we apply it to (E_0,θ_0) before applying φ_y = 90°. We would obtain (E_x,θ_x) = (cos(45°),45°) first, followed by (E_y,θ_y) = (cos^2(45°),90°) = (0.5,90°). Therefore adding an extra filter can increase the strength of the final beam! This is illustrated by a double-projection: In this problem, we would like to pass a beam \textbf{(E_0, θ_0) = (1, 0°)} sequentially through m fixed filters \textbf{φ_1}, \textbf{φ_2}, ..., \textbf{φ_m}. The intermediate beam emerging from filter \textbf{φ_i} is \textbf{(E_i, θ_i) = (E_i, φ_i)}. We also have \textbf{n} extra filters that can have any angle, and can be placed before any fixed filter. Our objective is to find the maximum possible output field strength \textbf{E_m}. \includegraphics{https://static.e-olymp.com/content/81/81280715a6a231bc7b88519ec98cd9e2cc262cde.jpg} Suppose each fixed filter \textbf{φ_i} is allotted \textbf{k_i} extra filters that interact with beam \textbf{(E_i_\{−1\}, θ_i_\{−1\})} first (\textbf{n} = \textbf{k_1} + \textbf{k_2} + ... + \textbf{k_m}). The \textbf{k_i} extra filters before \textbf{φ_i} will have angles that evenly span between \textbf{θ_i_\{−1\}} and \textbf{θ_i = φ_i}, along the acute (or right) angle between \textbf{θ_i_\{−1\}} and \textbf{φ_i}. An example with \textbf{k_i = 3} is shown on the right: Using this method, the following formula can be derived: \includegraphics{https://static.e-olymp.com/content/03/0377b1c4f794a078386cf0fecfb9a7a4938955e5.jpg} where \textbf{f(Δ,k)} for \textbf{0°} ≤ \textbf{Δ} < \textbf{180°} and \textbf{k} ≥ \textbf{0} is defined as: \includegraphics{https://static.e-olymp.com/content/62/62b36a79b30c05feeb7c60a3e4f1a9315a38a50a.jpg} . If \textbf{k_i = 0} (no extra filter inserted) the formula degenerates into \textbf{E_i = E_\{i−1\}|cos(θ_i−φ_i_\{−1\})|}. Since \textbf{(E_0, θ_0) = (1, 0°)}, the expression for the final output strength is: \includegraphics{https://static.e-olymp.com/content/68/68dc4c7ac20aa71c6fae4a191b305333caaed746.jpg} . Given \textbf{m}, \textbf{n}, and \textbf{φ_1}, \textbf{φ_2}, ..., \textbf{φ_m}, your task is to compute the maximum possible \textbf{E_m}. \InputFile The first input line contains the number of test cases \textbf{N}, \textbf{1} ≤ \textbf{N} ≤ \textbf{100}. Each test case begins with integers \textbf{m} and \textbf{n}, separated by space. \textbf{m} lines follow, each containing an integer \textbf{φ_i} (for \textbf{1} ≤ \textbf{i} ≤ \textbf{n}). \begin{itemize} \item \textbf{m} is the number of fixed filters, and satisfies \textbf{1} ≤ \textbf{m} ≤ \textbf{10}. \item \textbf{n} is the number of extra filters, and satisfies \textbf{0} ≤ \textbf{n} ≤ \textbf{100}. \item \textbf{φ_i} is the filter angle (in degrees) for the i'th fixed filter, and satisfies \textbf{0} ≤ \textbf{m} < \textbf{180}. \end{itemize} \textit{\textbf{Note:}} Remember to convert degrees to radians before using cos(). \OutputFile For each test case, print the maximum possible magnitude for \textbf{φ_m}, to \textbf{8} decimal places.
Zaman məhdudiyyəti 1 saniyə
Yaddaşı istafadə məhdudiyyəti 64 MiB
Giriş verilənləri #1
6
1 0
90
1 1
90
1 100
1
2 2
80
134
6 23
79
131
66
75
11
170
3 100
0
0
0
Çıxış verilənləri #1
0.00000000
0.50000000
0.99999849
0.46587532
0.64062165
1.00000000
Mənbə University of Toronto 2010 ACM Tryout: Saturday, October 2, 2010