A1. Generate superposition of all basis states

Codeforces
IDCF1002A1
Time1000ms
Memory256MB
Difficulty
English · Original
Chinese · Translation
Formal · Original
You are given _N_ qubits (1 ≤ _N_ ≤ 8) in zero state . Your task is to generate an equal superposition of all 2_N_ basis vectors on _N_ qubits: For example, * for _N_ = 1, the required state is simply , * for _N_ = 2, the required state is . You have to implement an operation which takes an array of _N_ qubits as an input and has no output. The "output" of the operation is the state in which it leaves the qubits. Your code should have the following signature: namespace Solution { open Microsoft.Quantum.Primitive; open Microsoft.Quantum.Canon; operation Solve (qs : Qubit\[\]) : () { body { // your code here } } } [samples]
给定 #cf_span[N] 个量子比特(#cf_span[1 ≤ N ≤ 8]),初始处于零态。 你的任务是生成在 #cf_span[N] 个量子比特上所有 #cf_span[2N] 个基矢的等权叠加态: 例如, 你需要实现一个操作,该操作以一个包含 #cf_span[N] 个量子比特的数组作为输入,且无输出。该操作的“输出”是其作用后量子比特所处的状态。 你的代码应具有如下签名: [samples]
**Definitions** Let $ N \in \mathbb{Z} $ with $ 1 \leq N \leq 8 $. Let $ \mathcal{H} = (\mathbb{C}^2)^{\otimes N} $ be the Hilbert space of $ N $ qubits. Let $ \{|x\rangle \mid x \in \{0,1\}^N\} $ be the computational basis of $ \mathcal{H} $, with $ |x\rangle $ denoting the computational basis state corresponding to bitstring $ x $. **Constraints** The initial state of the system is $ |0\rangle^{\otimes N} $. **Objective** Implement a unitary operation $ U $ such that: $$ U |0\rangle^{\otimes N} = \frac{1}{\sqrt{2^N}} \sum_{x \in \{0,1\}^N} |x\rangle $$ The operation $ U $ acts on $ N $ qubits and has no classical output; the result is the final quantum state of the qubits.
API Response (JSON)
{
  "problem": {
    "name": "A1. Generate superposition of all basis states",
    "description": {
      "content": "You are given _N_ qubits (1 ≤ _N_ ≤ 8) in zero state . Your task is to generate an equal superposition of all 2_N_ basis vectors on _N_ qubits: For example, *   for _N_ = 1, the required state is s",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF1002A1"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given _N_ qubits (1 ≤ _N_ ≤ 8) in zero state .\n\nYour task is to generate an equal superposition of all 2_N_ basis vectors on _N_ qubits:\n\nFor example,\n\n*   for _N_ = 1, the required state is s...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "给定 #cf_span[N] 个量子比特(#cf_span[1 ≤ N ≤ 8]),初始处于零态。\n\n你的任务是生成在 #cf_span[N] 个量子比特上所有 #cf_span[2N] 个基矢的等权叠加态:\n\n例如,\n\n你需要实现一个操作,该操作以一个包含 #cf_span[N] 个量子比特的数组作为输入,且无输出。该操作的“输出”是其作用后量子比特所处的状态。\n\n你的代码应具有如下签名:\n\n[...",
      "is_translate": true,
      "language": "Chinese"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ N \\in \\mathbb{Z} $ with $ 1 \\leq N \\leq 8 $.  \nLet $ \\mathcal{H} = (\\mathbb{C}^2)^{\\otimes N} $ be the Hilbert space of $ N $ qubits.  \nLet $ \\{|x\\rangle \\mid x \\in \\{0,1\\}^N\\}...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments