{"raw_statement":[{"iden":"statement","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 superposition of all basis states on _N_ qubits that have Hamming weight equal to 1:\n\nFor example, for _N_ = 1, .\n\nYou 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.\n\nYour code should have the following signature:\n\nnamespace Solution {\n    open Microsoft.Quantum.Primitive;\n    open Microsoft.Quantum.Canon;\n\n    operation Solve (qs : Qubit\\[\\]) : ()\n    {\n        body\n        {\n            // your code here\n        }\n    }\n}"}],"translated_statement":[{"iden":"statement","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] 个量子比特的数组作为输入，且无输出。该操作的“输出”是它作用后量子比特所处的状态。\n\n你的代码应具有以下签名：\n\n"}],"sample_group":[],"show_order":[],"formal_statement":"**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 x \\in \\{0,1\\}^N\\} $ be the computational basis of $ \\mathcal{H} $.  \n\nThe **generalized W state** on $ N $ qubits is defined as:  \n$$\n|W_N\\rangle = \\frac{1}{\\sqrt{N}} \\sum_{i=1}^{N} |e_i\\rangle\n$$  \nwhere $ |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)} $).\n\n**Constraints**  \n1. $ N = 2^k $ for $ k \\in \\{0, 1, 2, 3, 4\\} $, so $ N \\in \\{1, 2, 4, 8, 16\\} $.  \n2. The input state is $ |0\\rangle^{\\otimes N} $.  \n3. The operation must be unitary and leave no ancillae uncomputed.  \n\n**Objective**  \nImplement a unitary operation $ U $ such that:  \n$$\nU |0\\rangle^{\\otimes N} = |W_N\\rangle\n$$","simple_statement":null,"has_page_source":false}