Problem Statement
You are given an integer n.
Implement the operation of preparing the state ∣ψ⟩ from the zero state on a quantum circuit qc with n qubits.
The state ∣ψ⟩ is defined as
∣ψ⟩=n1(∣10...0⟩n+∣010...0⟩n+⋯+∣0...01⟩n).
Constraints
- 2≤n≤15
- Global phase is ignored in judge.
- The submitted code must follow the specified format:
from qiskit import QuantumCircuit
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
return qc
Sample Input
- n=4:
Implemented circuit qc should perform the following transformation.
∣0000⟩qc41(∣1000⟩+∣0100⟩+∣0010⟩+∣0001⟩)