Problem Statement
You are given an integer n.
Implement the operation defined by the following matrix A on a quantum circuit qc with n qubits:
A=2∣ψ⟩⟨ψ∣−I
where I denotes the 2n×2n identity matrix and ∣ψ⟩ is defined by
∣ψ⟩=2n1i=0∑2n−1∣i⟩.
Constraints
- 2≤n≤10
- 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
def solve(n: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
return qc
Sample Input
- n=2, ∣ψ⟩=41(∣00⟩+∣10⟩+∣01⟩+∣11⟩):
The matrix A is calculated as follows.
A=2∣ψ⟩⟨ψ∣−I=−0.50.50.50.50.5−0.50.50.50.50.5−0.50.50.50.50.5−0.5