B5: Quantum Arithmetic I

実行時間制限:3 秒

メモリ制限:512 MiB

配点:200点

Problem Statement

You are given integers n, m, S0, S1, ⋯ , Sn−1n,\ m,\ S_0,\ S_1,\ \cdots,\ S_{n-1}.

For an integer x=x0+21x1+⋯2n−1xn−1x = x_0 + 2^1 x_1 + \cdots 2^{n-1}x_{n-1} (xi∈{0,1})\left(x_i \in \{0, 1\}\right) in the range from 00 (inclusive) to 2n2^n (exclusive), define the function f(x)f(x) by

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

Implement the nn-qubit oracle OO acting on computational basis states as

∣x⟩n→Oexp⁡(2πif(x)2m)∣x⟩n\begin{equation} \ket{x}_n \xrightarrow{O} \exp{\left(\frac{2\pi i f(x)}{2^m}\right)}\ket{x}_n \nonumber \end{equation}

for any integer xx in the range from 00 (inclusive) to 2n2^n (exclusive).

Constraints

  • 1≤n,m≤101 \leq n, m \leq 10
  • 0≤Sk<2m0 \leq S_k < 2^m
  • The quantum circuit depth must not exceed 1010.
  • Integers must be encoded by little-endian.
  • Global phase is ignored in judge.
  • The submitted code must follow the specified format:
from qiskit import QuantumCircuit
 
 
def solve(n: int, m: int, S: list[int]) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
 
    return qc

Sample Input

  • n=2, m=2, S0=1, S1=3, ∣x⟩=∣11⟩=∣3⟩n=2,\ m = 2,\ S_0 = 1,\ S_1 = 3,\ \ket{x} = \ket{11} = \ket{3}: Since f(3)=1⋅1+3⋅1=4f(3) = 1 \cdot 1 + 3 \cdot 1 = 4, Implemented quantum circuit qc\mathrm{qc} should perform the following transformation.
∣11⟩→qcexp⁡(2⋅4πi22)∣11⟩\ket{11} \xrightarrow{\mathrm{qc}} \exp{\left(\frac{2 \cdot 4\pi i}{2^2}\right)}\ket{11}

解答を提出するにはログインしてください。