B1: Action in the Fourier Basis

Time Limit: 3 sec

Memory Limit: 512 MiB

Score: 300

Problem Statement

Let nn be a positive integer. For an integer kk with 0k<2n0 \leq k < 2^n, define QFT(k)\mathrm{QFT}(k) as the following state:

QFT(k)=12n0a<2nωaka,\mathrm{QFT}(k) = \frac{1}{\sqrt{2^n}} \sum_{0 \leq a < 2^n} \omega^{ak} \ket{a},

where

ω=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}.

The oracle OO must satisfy

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

where kk' is an integer satisfying

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

Constraints

  • 2n102 \leq n \leq 10
  • 0kconst<2n0 \leq k_{\text{const}} < 2^n
  • The 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 circuit qc\mathrm{qc} should perform the following transformation.
14(0+ωk1+ω2k2+ω3k3)qc14(0+ωk1+ω2k2+ω3k3)\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++2n1an1a = 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.