C1: Generate Uniform Amplitude Superposition State I

Time Limit: 3 sec

Memory Limit: 512 MiB

Score: 300

Problem Statement

You are given integers nn and LL. Implement the operation of preparing the state ψ\ket{\psi} on a quantum circuit qc\mathrm{qc} with nn qubits such that the states 0, 1, ... L1\ket{0},\ \ket{1},\ ...\ \ket{L-1} are observed with equal probabilities, and the sum of these probabilities exceeds 0.50.5.

More Precise Problem Statement

Define the state ψ\ket{\psi} prepared by qc\mathrm{qc} as

ψ=i=02n1aii,\begin{equation} \ket{\psi} = \sum_{i=0}^{2^n-1} a_i\ket{i}, \nonumber \end{equation}

where aia_i denotes the probability amplitude of the computational basis state i\ket{i}.

Implement qc\mathrm{qc} satisfying following conditions:

  • a0=a1==aL1|a_0| = |a_1| = \cdots = |a_{L-1}|
  • i=0L1ai2>0.5\sum_{i=0}^{L-1} |a_i|^2 > 0.5

Constraints

  • 1n101 \leq n \leq 10
  • 1L2n1 \leq L \leq 2^n
  • Integers must be encoded by little-endian notation, i.e., 100=1001\ket{100} = 1 \neq \ket{001}.
  • The submitted code must follow the specified format:
from qiskit import QuantumCircuit
 
 
def solve(n: int, L: int) -> QuantumCircuit:
    qc = QuantumCircuit(n)
    # Write your code here:
 
    return qc

Sample Input

  • n=3, L=3n = 3,\ L=3: Implemented circuit qc\mathrm{qc} should perform the following transformation.
000qc13(000+100+010)=13(0+1+2)\ket{000} \xrightarrow{\mathrm{qc}} \frac{1}{\sqrt{3}} (\ket{000} + \ket{100} + \ket{010}) = \frac{1}{\sqrt{3}} (\ket{0} + \ket{1} + \ket{2})

Please sign in to submit your answer.