B1: Action in the Fourier Basis

Time Limit: 3 seconds

Memory Limit: 512 MiB

Score: 300 points

Problem Statement

Let nn be a positive integer. For a nonnegative integer kk, define QFT(k)\mathrm{QFT}(k) as the state obtained by applying the quantum Fourier transform (QFT) to the computational basis state ∣k mod 2n⟩\ket{k \bmod 2^n}:

QFT(k)=12n∑0≤a<2nωak∣a⟩\mathrm{QFT}(k) = \frac{1}{\sqrt{2^n}} \sum_{0 \leq a < 2^n} \omega^{ak} \ket{a}

where ω\omega is defined by

ω=exp⁡(2πi2n)\omega = \exp \left( {\frac{2 \pi i}{2^n}} \right)

Given integers nn and kconstk_{\text{const}}, implement an nn-qubit oracle OO on a quantum circuit qc\mathrm{qc}.

For any integer kk satisfying 0≤k<2n0 \leq k < 2^n, the oracle must satisfy

QFT(k)→OQFT(k′)\mathrm{QFT}(k) \xrightarrow{O} \mathrm{QFT}(k')

where 0≤k′<2n0 \leq k' < 2^{n} must satisfy

ωk′=ωkconstωk\omega^{k'} = \omega^{k_{\text{const}}} \omega^{k}

Constraints

  • 2≤n≤102 \leq n \leq 10
  • 0≤kconst<2n0 \leq k_{\text{const}} < 2^n
  • The quantum circuit depth must not exceed 11.
  • 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=2n = 2: Implemented quantum circuit qc\mathrm{qc} should perform the following transformation.
14(∣0⟩+ωk∣1⟩+ω2k∣2⟩+ω3k∣3⟩)→qc14(∣0⟩+ωk′∣1⟩+ω2k′∣2⟩+ω3k′∣3⟩)\frac{1}{\sqrt{4}} \left( \ket{0} + \omega^{k} \ket{1} + \omega^{2k} \ket{2} + \omega^{3k} \ket{3} \right) \xrightarrow{\mathrm{qc}} \frac{1}{\sqrt{4}} \left( \ket{0} + \omega^{k'} \ket{1} + \omega^{2k'} \ket{2} + \omega^{3k'} \ket{3} \right)

Hints

Open
  • Thinking of aa as a binary expansion a=a0+2a1+⋯+2n−1an−1a = a_0 + 2 a_1 + \cdots + 2^{n-1} a_{n-1} may make it easier to solve.
  • Related problem: QCoder Programming Contest 002 - B5

Please sign in to submit your answer.