Problem Statement
You are given integers n, m, S0, S1, ⋯, Sn−1.
For an integer x=x0+21x1+⋯2n−1xn−1 (xi∈{0,1}) where 0≤x<2n, define the function f(x) by
f(x)=S0x0+S1x1+⋯+Sn−1xn−1.
Implement the (n+m)-qubit oracle O acting on computational basis states as
∣x⟩n∣y⟩mO∣x⟩n∣(y+f(x))(mod 2m)⟩m
for any pair of integers (x, y) such that 0≤x<2n and 0≤y<2m.
Constraints
- 1≤n,m≤9
- n+m≤10
- 0≤Sk<2m
- The circuit depth must not exceed 50.
- 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, QuantumRegister
def solve(n: int, m: int, S: list[int]) -> QuantumCircuit:
x, y = QuantumRegister(n), QuantumRegister(m)
qc = QuantumCircuit(x, y)
# Write your code here:
return qc