#P12528. [XJTUPC 2025] 量子力学

    ID: 12361 远端评测题 1000ms 256MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>2025Special JudgeO2优化高校校赛

[XJTUPC 2025] 量子力学

Description

MCPlayer542 has recently been studying "Quantum Computation and Quantum Information". He is very interested in the representation of quantum states.

Unlike classical bits, a qubit can not only be in the state 0|0\rangle or the state 1|1\rangle, but can also be in a superposition state between 0|0\rangle and 1|1\rangle.

The state of a quantum system composed of nn qubits is usually represented by a 2n2^n-dimensional complex vector ψ|\psi\rangle, where the product of the ii-th complex number and its conjugate represents the probability of the state of these nn quantum bits being equal to the binary representation of ii, after a quantum measurement on the computational basis.

For example, when you perform a quantum measurement on a two-qubit system represented by $|\phi\rangle=[\frac12,\frac12-\frac{\bf{i}}2,0,\frac{\bf{i}}2]^T$, it will be in the state 00|00\rangle with a probability of 12×12=14\frac12 \times \frac12 = \frac14, in the state 01|01\rangle with a probability of $(\frac12-\frac{\bf{i}}2) \times (\frac12+\frac{\bf{i}}2) = \frac14+\frac14 = \frac12$, in the state 10|10\rangle with a probability of 0×0=00 \times 0 = 0, and in the state 11|11\rangle with a probability of i1×(i1)=14\frac{\bf{i}}1 \times (-\frac{\bf{i}}1) = \frac14.

Now he has a quantum state ψ|\psi\rangle with nn quantum bits. Please help him calculate the probabilities of each qubit being in the states 0|0\rangle and 1|1\rangle after a measurement on the computational basis, respectively.

Input Format

The first line contains a positive integer nn (1n81 \le n \le 8), representing the number of quantum bits in the system.

The next 2n2^n lines contain the ii-th line with two real numbers aia_i and bib_i, separated by a space, representing the real part and the imaginary part of the ii-th component of the quantum system vector, respectively.

The data guarantees that the sum of the probabilities of the quantum system being in all states does not exceed an absolute or relative error of 10610^{-6} from 11.

Output Format

Output nn lines, each containing two real numbers p0p_0 and p1p_1, separated by a space, representing the probabilities of each quantum bit being in the state 0|0\rangle and the state 1|1\rangle after the measurement, respectively.

Your output will be considered correct if and only if the absolute or relative error from the correct answer does not exceed 10610^{-6}.

2
0.5 0
0.5 -0.5
0 0
0 0.5
0.250000000 0.750000000
0.750000000 0.250000000