Problem Statement
You are given an integer . Implement the oracle on a quantum circuit consisting of an -qubit register and a -qubit register , and acting on the computational basis states as
Here, denotes the -th qubit of .
Constraints
- Global phase is ignored in judge.
- The submitted code must follow the specified format:
from qiskit import QuantumCircuit, QuantumRegister
def solve(n: int) -> QuantumCircuit:
x, y = QuantumRegister(n), QuantumRegister(1)
qc = QuantumCircuit(x, y)
# Write your code here:
return qcSample Input
- : The implemented oracle should perform the following transformation.
Hints
Open
- You can get the number of qubits in as follows:
n = len(x)- You can apply the quantum gate to the -th qubit of as follows:
qc.g(x[i - 1])