B1: Uniform Superposition

Time Limit: 3 seconds

Memory Limit: 512 MiB

Score: 100 points

Problem Statement

You are given an integer nn.

Implement the operation of preparing the uniform superposition state ∣A⟩\ket{A} from the zero state on a quantum circuit qc\mathrm{qc} with nn qubits.

The uniform superposition state ∣A⟩\ket{A} is defined as

∣A⟩n=12n∑i=02n−1∣i⟩=12n(∣0...0⟩n+...+∣1...1⟩n).\begin{align} \ket{A}_n &= \frac{1}{\sqrt{2^n}} \sum_{i=0}^{2^n-1} \ket{i} \nonumber\\ & = \frac{1}{\sqrt{2^n}} (\ket{0...0}_n + ... + \ket{1...1}_n). \nonumber \end{align}

Constraints

  • 1≤n≤101 \leq n \leq 10
  • 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=2n = 2: Implemented circuit qc\mathrm{qc} should perform the following transformation.
∣00⟩→qc14(∣00⟩+∣10⟩+∣01⟩+∣11⟩)\ket{00} \xrightarrow{\mathrm{qc}} \frac{1}{\sqrt{4}} (\ket{00} + \ket{10} + \ket{01} + \ket{11})

Hints

Open
  • You can apply the quantum gate gg to all the qubits of the quantum circuit qc\mathrm{qc} as follows:
qc.g(range(n))

Please sign in to submit your answer.