Problem Statement
You are given an integer and an oracle . For any pair of integers satisfying and , the oracle satisfies
where denotes the XOR operator, and is a function that returns either or for any integer with .
Implement an operation on a quantum circuit that satisfies
for any integer satisfying .
Constraints
- 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
"""
You can apply oracle as follows:
qc.compose(o, inplace=True)
"""
def solve(n: int, o: QuantumCircuit) -> QuantumCircuit:
x, y = QuantumRegister(n), QuantumRegister(1)
qc = QuantumCircuit(x, y)
# Write your code here:
return qc
Sample Input
- : Implemented circuit should perform the following transformation.