Problem Statement
Let n be a positive integer. For an integer k with 0≤k<2n, define QFT(k) as the following state:
QFT(k)=2n10≤a<2n∑ωak∣a⟩,
where
ω=exp(2n2πi).
Given integers n and kconst, implement an n-qubit oracle O on a quantum circuit qc.
The oracle O must satisfy
QFT(k)OQFT(k′),
where k′ is an integer satisfying
ωk′=ωkconstωk.
Constraints
- 2≤n≤10
- 0≤kconst<2n
- The circuit depth must not exceed 1.
- 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, k_const: int) -> QuantumCircuit:
qc = QuantumCircuit(n)
# Write your code here:
return qc
Sample Input
- n=2:
Implemented circuit qc should perform the following transformation.
41(∣0⟩+ωk∣1⟩+ω2k∣2⟩+ω3k∣3⟩)qc41(∣0⟩+ωk′∣1⟩+ω2k′∣2⟩+ω3k′∣3⟩)
Hints
Open
- Thinking of a as a binary expansion a=a0+2a1+⋯+2n−1an−1 may make it easier to solve.
- Related problem: QCoder Programming Contest 002 - B5