A2: Generate Uniform Superposition State

Time Limit: 3 sec

Memory Limit: 512 MiB

Score: 200

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=12ni=02n1i=12n(0...0n+...+1...1n).\begin{align} \ket{A} &= \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

  • 1n101 \leq n \leq 10
  • Global phase is ignored in judge.
  • The submitted code must follow the specified format: ((format to be added during rendering))

Sample Input

  • n=2n = 2: Implemented circuit qc\mathrm{qc} should perform the following transformation.
00qc14(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.