×

计蒜客

  1. 题库
  2. Five Dimensional Discrete Fourier Transform
  3. 问答
  • 27.78%
  • 262144K

The five dimensional discrete fourier transform over a $n_1 \times n_2 \times n_3 \times n_4 \times n_5$ complex array $a[i_1][i_2][i_3][i_4][i_5]$ where $0 \le i_1 \le n_1-1,0 \le i_2 \le n_2-1,0 \le i_3 \le n_3-1,0 \le i_4 \le n_4-1 $ and $0 \le i_5 \le n_5 - 1$ is given by:

$$\displaystyle A[j_1][j_2][j_3][j_4][j_5] = \sum_{i_1=0}^{n_1-1} \cdot \cdot \cdot \sum_{i_5=0}^{n_5-1} a[i_1][i_2][i_3][i_4][i_5]e{-2 \pi \sqrt{1} (i_1j_1/n_1+ \cdot \cdot \cdot + i_5 j_5 /n_5)} $$

$for \ 0 \le j1 \le n_1 -1 \cdot \cdot \cdot , 0 \le j_5 \le n_5 - 1$

Now comes your turn. For a given real coefficient $α$, suppose

$$\displaystyle a[i_1][i_2][i_3][i_4][i_5]=( i_1 \ xor \ i_2 \ xor \ i_3 \ xor \ i_4 \ xor \ i_5 ) e^{ \sqrt{-1}(i_1-i_2+i_3-i_4+i_5) \alpha }$$

Please calculate the value of

$$\displaystyle \frac{1}{(n_1n_2n_3n_4n_5)^{1.5}} \cdot \cdot \cdot \sum_{i_5=0}^{n_5-1} |Re(A[i_1][i_2][i_3][i_4][i_5])|, $$

where Re means the real part of a complex number and | · · · | means the absolute value of real number.

Input

The first line of the input contains an integer $T (1 \le T \le 200)$ indicating the total number of test cases. For each test case, a line contains five integers $n_1, n_2, n_3, n_4, n_5$ where $1 \le n_1, n_2, n_3, n_4, n_5 \le 10$, and a float number $α (-100000 \le α \le 100000)$ with at most $10$ significance digits.

Output

For each test case, output the value with the precision of $6$ digits.

样例输入

5
1 1 1 1 2 9.8
1 1 1 1 4 3.14
1 2 1 2 1 8.777
2 1 1 1 2 8.777
1 2 3 2 1 20.1314

样例输出

0.657911
1.499989
0.398713
0.398713
0.942596

想挑战这道题吗

  • main.c