#P17217. [ICPC 2017 Nanning R] Five Dimensional Discrete Fourier Transform

[ICPC 2017 Nanning R] Five Dimensional Discrete Fourier Transform

Problem Description

The five dimensional discrete fourier transform over a n1×n2×n3×n4×n5n_1 \times n_2 \times n_3 \times n_4 \times n_5 complex array a[i1][i2][i3][i4][i5]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≤i5≤n5−10 \le i_5 \le n_5 - 1 is given by:

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

for $0 \le j_1 \le n_1 - 1, \dots, 0 \le j_5 \le n_5 - 1$.

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

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

Please calculate the value of

$$\frac{1}{(n_1 n_2 n_3 n_4 n_5)^{1.5}} \sum_{j_1=0}^{n_1-1} \cdots \sum_{j_5=0}^{n_5-1} |\text{Re}(A[j_1][j_2][j_3][j_4][j_5])|,$$

where Re\text{Re} means the real part of a complex number and ∣⋅∣|\cdot| means the absolute value of a real number.

Input Format

The first line of the input contains an integer T(1≤T≤200)T (1 \le T \le 200) indicating the total number of test cases. For each test case, a line contains five integers n1,n2,n3,n4,n5n_1, n_2, n_3, n_4, n_5 where 1≤n1,n2,n3,n4,n5≤101 \le n_1, n_2, n_3, n_4, n_5 \le 10, and a float number α(−100000≤α≤100000)\alpha (-100000 \le \alpha \le 100000) with at most 1010 significant digits.

Output Format

For each test case, output the value with the precision of 66 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