Problem Statement
You are given an integer . Implement the oracle on a quantum circuit consisting of qubits, and acting on the computational basis states as
denotes the first qubits of the circuit and denotes the last one.
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 qc
Sample 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])