B4: Quantum Fourier Transform

Time Limit: 3 sec

Memory Limit: 512 MiB

Score: 200

Problem Statement

You are given an integer nn.
Implement the quantum Fourier transform (QFT) for nn qubits.

The quantum Fourier transform is defined as a nn-qubit oracle QFT\mathrm{QFT} acting on computational basis states as

jnQFT12nk=02n1exp(2πijk2n)kn\begin{equation} \ket{j}_n \xrightarrow{\mathrm{QFT}} \sqrt{\frac{1}{2^n}} \sum_{k=0}^{2^n-1} \exp{\left(\frac{2\pi i j k}{2^n}\right)} \ket{k}_n \nonumber \end{equation}

for any integer jj such that 0j<2n0 \leq j < 2^n.

Constraints

  • 1n101 \leq n \leq 10
  • The circuit depth must not exceed 2525.
  • Integers are encoded by little-endian notation, i.e., 100=1001\ket{100} = 1 \neq \ket{001}.
  • Changes in the global phase are ignored.
  • The submitted code must follow the specified format:
from qiskit import QuantumCircuit
 
 
def solve(n: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
 
    return qc

Sample Input

  • n=2n = 2
    The implemented quantum circuit qc\mathrm{qc} should perform the following transformation.
10qc14(00+eπi/210+eπi01+e3πi/211)\ket{10} \xrightarrow{\mathrm{qc}} \frac{1}{\sqrt{4}} (\ket{00} + e^{\pi i / 2}\ket{10} + e^{\pi i}\ket{01} + e^{3 \pi i / 2}\ket{11})

Hints

Open
  • Please be aware that the circuit must be implemented assuming little-endian.

Please sign in to submit your answer.