Problem Statement
Given an integer , implement an -qubit oracle on a quantum circuit .
The oracle acts on basis states , where and , as follows:
- If ,
- Otherwise,
Here, denotes the XOR operator.
Constraints
- The circuit depth must not exceed .
- 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) -> QuantumCircuit:
m, k = QuantumRegister(1), QuantumRegister(n)
qc = QuantumCircuit(m, k)
# Write your code here:
return qc
Hints
Open
- You can consider the way to apply the approach in Problem A2.