B8: Quantum Arithmetic IV

Time Limit: 3 sec

Memory Limit: 512 MiB

Score: 200

Problem Statement

You are given integers n, m, L, S0, S1, , Sn1n,\ m,\ L,\ S_0,\ S_1,\ \cdots,\ S_{n-1} and a real number θ\theta.

For an integer x=x0+21x1+2n1xn1x = x_0 + 2^1 x_1 + \cdots 2^{n-1}x_{n-1} (xi{0,1})\left(x_i \in \{0, 1\}\right) where 0x<2n0 \leq x < 2^n, define the function f(x)f(x) by

f(x)=S0x0+S1x1++Sn1xn1.\begin{equation} f(x) = S_0 x_0 + S_1 x_1 + \cdots + S_{n-1}x_{n-1} \nonumber \end{equation}.

Implement the (n+m)(n + m)-qubit oracle OO acting on computational basis states as

xn0mO{eiθxn0mf(x)=L (mod 2m)eiθxn0mf(x)L (mod 2m)\begin{equation} \ket{x}_{n}\ket{0}_{m} \xrightarrow{O} \begin{cases} e^{i\theta} \ket{x}_{n}\ket{0}_{m} & f(x) = L\ (\mathrm{mod}\ 2^m) \\ \phantom{e^{i\theta}} \ket{x}_{n}\ket{0}_{m} & f(x) \neq L\ (\mathrm{mod}\ 2^m) \end{cases} \nonumber \end{equation}

for any integer xx such that 0x<2n0 \leq x < 2^n.

Constraints

  • 1n,m91 \leq n, m \leq 9
  • n+m10n + m \leq 10
  • 0L<2m0 \leq L < 2^m
  • 0Sk<2m0 \leq S_k < 2^m
  • 0θ<2π0 \leq \theta < 2\pi
  • The circuit depth must not exceed 100100.
  • 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, QuantumRegister
 
 
def solve(n: int, m: int, L: int, S: list[int], theta: float) -> QuantumCircuit:
    x, y = QuantumRegister(n), QuantumRegister(m)
    qc = QuantumCircuit(x, y)
    # Write your code here:
 
    return qc

Please sign in to submit your answer.