{"raw_statement":[{"iden":"statement","content":"You are given _N_ qubits (2 ≤ _N_ ≤ 8) which are guaranteed to be in one of the two states:\n\n*   state, or\n*   state.Your task is to perform necessary operations and measurements to figure out which state it was and to return 0 if it was state or 1 if it was W state. The state of the qubits after the operations does not matter.\n    \n    You have to implement an operation which takes an array of _N_ qubits as an input and returns an integer.\n    \n    Your code should have the following signature:\n    \n    namespace Solution {\n        open Microsoft.Quantum.Primitive;\n        open Microsoft.Quantum.Canon;\n    \n        operation Solve (qs : Qubit\\[\\]) : Int\n        {\n            body\n            {\n                // your code here\n            }\n        }\n    }"}],"translated_statement":[{"iden":"statement","content":"给定 #cf_span[N] 个量子比特（#cf_span[2 ≤ N ≤ 8]），它们保证处于以下两种状态之一：\n\n你的任务是执行必要的操作和测量，以确定其处于哪种状态，并在是 $|0\\dots0\\rangle$ 态时返回 0，在是 $|W\\rangle$ 态时返回 1。操作后量子比特的状态无关紧要。\n\n你需要实现一个操作，该操作以一个包含 #cf_span[N] 个量子比特的数组作为输入，并返回一个整数。\n\n你的代码应具有以下签名：\n\n"}],"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ N \\in \\mathbb{Z} $ with $ 2 \\leq N \\leq 8 $.  \nLet $ \\mathcal{H} = (\\mathbb{C}^2)^{\\otimes N} $ be the Hilbert space of $ N $ qubits.  \nLet $ |\\psi_0\\rangle = |0\\rangle^{\\otimes N} $ denote the $ |0\\rangle^{\\otimes N} $ state.  \nLet $ |\\psi_1\\rangle = |W_N\\rangle = \\frac{1}{\\sqrt{N}} \\sum_{i=1}^N |0\\rangle^{\\otimes (i-1)} |1\\rangle |0\\rangle^{\\otimes (N-i)} $ denote the $ N $-qubit W state.  \n\nThe input qubit register is guaranteed to be in one of the two states: $ |\\psi_0\\rangle $ or $ |\\psi_1\\rangle $.\n\n**Objective**  \nImplement a quantum operation that, given an $ N $-qubit register in either $ |\\psi_0\\rangle $ or $ |\\psi_1\\rangle $, outputs:  \n$$\n\\begin{cases}\n0 & \\text{if the state is } |\\psi_0\\rangle \\\\\n1 & \\text{if the state is } |\\psi_1\\rangle\n\\end{cases}\n$$  \nThe output is obtained via measurement(s) and classical post-processing. The final state of the qubits after the operation is irrelevant.","simple_statement":null,"has_page_source":false}