A4. Generate W state

Codeforces
IDCF1002A4
Time1000ms
Memory256MB
Difficulty
English · Original
Chinese · Translation
Formal · Original
You are given _N_ = 2_k_ qubits (0 ≤ _k_ ≤ 4) in zero state . Your task is to create a generalized [W state](https://en.wikipedia.org/wiki/W_state) on them. Generalized W state is an equal superposition of all basis states on _N_ qubits that have Hamming weight equal to 1: For example, for _N_ = 1, . 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 = 2k] 个量子比特(#cf_span[0 ≤ k ≤ 4]),它们均处于零态。你的任务是为它们构造一个广义 W 态。广义 W 态是所有在 #cf_span[N] 个量子比特上汉明重量等于 1 的基态的等权叠加: 例如,当 #cf_span[N = 1] 时, 。 你需要实现一个操作,该操作以一个包含 #cf_span[N] 个量子比特的数组作为输入,且无输出。该操作的“输出”是它作用后量子比特所处的状态。 你的代码应具有以下签名: [samples]
**Definitions** Let $ N = 2^k $ for some $ k \in \mathbb{Z} $, $ 0 \leq k \leq 4 $. 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} $. The **generalized W state** on $ N $ qubits is defined as: $$ |W_N\rangle = \frac{1}{\sqrt{N}} \sum_{i=1}^{N} |e_i\rangle $$ where $ |e_i\rangle $ is the basis state with Hamming weight 1 and the single $ 1 $ at position $ i $ (i.e., $ |e_i\rangle = |0\rangle^{\otimes (i-1)} \otimes |1\rangle \otimes |0\rangle^{\otimes (N-i)} $). **Constraints** 1. $ N = 2^k $ for $ k \in \{0, 1, 2, 3, 4\} $, so $ N \in \{1, 2, 4, 8, 16\} $. 2. The input state is $ |0\rangle^{\otimes N} $. 3. The operation must be unitary and leave no ancillae uncomputed. **Objective** Implement a unitary operation $ U $ such that: $$ U |0\rangle^{\otimes N} = |W_N\rangle $$
API Response (JSON)
{
  "problem": {
    "name": "A4. Generate W state",
    "description": {
      "content": "You are given _N_ = 2_k_ qubits (0 ≤ _k_ ≤ 4) in zero state . Your task is to create a generalized [W state](https://en.wikipedia.org/wiki/W_state) on them. Generalized W state is an equal superpositi",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF1002A4"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given _N_ = 2_k_ qubits (0 ≤ _k_ ≤ 4) in zero state . Your task is to create a generalized [W state](https://en.wikipedia.org/wiki/W_state) on them. Generalized W state is an equal superpositi...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "给定 #cf_span[N = 2k] 个量子比特(#cf_span[0 ≤ k ≤ 4]),它们均处于零态。你的任务是为它们构造一个广义 W 态。广义 W 态是所有在 #cf_span[N] 个量子比特上汉明重量等于 1 的基态的等权叠加:\n\n例如,当 #cf_span[N = 1] 时, 。\n\n你需要实现一个操作,该操作以一个包含 #cf_span[N] 个量子比特的数组作为输入,且无输出。该...",
      "is_translate": true,
      "language": "Chinese"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ N = 2^k $ for some $ k \\in \\mathbb{Z} $, $ 0 \\leq k \\leq 4 $.  \nLet $ \\mathcal{H} = (\\mathbb{C}^2)^{\\otimes N} $ be the Hilbert space of $ N $ qubits.  \nLet $ \\{|x\\rangle \\mid ...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments