eolymp
bolt
Try our new interface for solving problems
Problems

Bifurcation

Bifurcation

Denote two sequences of real numbers \textbf{x}(\textbf{k}) and \textbf{y}(\textbf{k}). We define a sequence of complex numbers \textbf{z}(\textbf{k}): \textbf{z}(\textbf{k}) = \textbf{x}(\textbf{k}) + \textbf{iy}(\textbf{k}). \includegraphics{file:///C:/Temp/moz-screenshot-16.png} \includegraphics{file:///C:/Temp/moz-screenshot-15.png} \includegraphics{https://static.e-olymp.com/content/9a/9ab843ceb0f04a2f1ae7997a561ebdd426585517.jpg} Let \textbf{FFT_N}(\textbf{k}, \textbf{z}) = . Defined similarly \textbf{FFT_N}(\textbf{k}, \textbf{x}) and \textbf{FFT_N}(\textbf{k}, \textbf{y}). Required by the calculated values \textbf{FFT_N}(\textbf{k}, \textbf{z}) to restore the values \textbf{FFT_N}(\textbf{k}, \textbf{x}) and \textbf{FFT_N}(\textbf{k}, \textbf{y}). \InputFile The first line of the input file contains an integer \textbf{N} (\textbf{1} ≤ \textbf{N} ≤ \textbf{2^30}, \textbf{N} is a power of two). Followed by non-negative integers \textbf{A}, \textbf{B}, \textbf{C}, \textbf{D}, \textbf{E}, \textbf{F}, do not exceed \textbf{1000}. To save time entering a value \textbf{FFT_N}(\textbf{k}, \textbf{z}) must be calculated as follows: \textbf{FFT_N}(\textbf{k}, \textbf{z})\textbf{.real} = ((\textbf{A} + \textbf{B}·\textbf{k}) \textbf{xor} (\textbf{C}·\textbf{k}))·\textbf{10^\{-3\}}, \textbf{FFT_N}(\textbf{k}, \textbf{z})\textbf{.imag} = ((\textbf{D} + \textbf{E}·\textbf{k}) \textbf{xor} (\textbf{F}·\textbf{k}))·\textbf{10^\{-3\}}, where \textbf{FFT_N}(\textbf{k}, \textbf{z})\textbf{.real} and \textbf{FFT_N}(\textbf{k}, \textbf{z})\textbf{.imag} --- real and imaginary parts, respectively. Then, given the number of \textbf{M} - the number of queries (\textbf{1} ≤ \textbf{M} ≤ \textbf{10^5}). Followed by \textbf{M} integers \textbf{q_i} (\textbf{0} ≤ \textbf{q_i} ≤ \textbf{N}). \OutputFile The output file output the \textbf{M} lines. In the \textbf{j}-th line \textbf{FFT_N}(\textbf{q_j}, \textbf{x}) and \textbf{FFT_N}(\textbf{g_j}, \textbf{y}). Values should be different from the right is not more than \textbf{10^\{-4\}}.
Time limit 2 seconds
Memory limit 256 MiB
Input example #1
2
1000 0 0 0 0 0
2
0 1
Output example #1
1.0000 0.0000 0.0000 0.0000
1.0000 0.0000 0.0000 0.0000
Author Dmitriy Zhukov
Source Winter School, Kharkov, 2011, Day 2