A. Generate plus state or minus state

Codeforces
IDCF1001A
Time1000ms
Memory256MB
Difficulty
English · Original
Chinese · Translation
Formal · Original
You are given a qubit in state and an integer _sign_. Your task is to convert the given qubit to state if _sign_ = 1 or if _sign_ =  - 1. ## Input You have to implement an operation which takes a qubit and an integer as an input and has no output. The "output" of your solution is the state in which it left the input qubit. Your code should have the following signature: namespace Solution { open Microsoft.Quantum.Primitive; open Microsoft.Quantum.Canon; operation Solve (q : Qubit, sign : Int) : () { body { // your code here } } } [samples]
给定一个处于状态 的量子比特和一个整数 #cf_span[sign]。 你的任务是:如果 #cf_span[sign = 1],将该量子比特转换为状态 ;如果 #cf_span[sign =  - 1],将其转换为状态 。 你需要实现一个操作,该操作以一个量子比特和一个整数作为输入,且无输出。你的解决方案的“输出”是其作用后量子比特所处的状态。 你的代码应具有以下签名: ## Input 你需要实现一个操作,该操作以一个量子比特和一个整数作为输入,且无输出。你的解决方案的“输出”是其作用后量子比特所处的状态。你的代码应具有以下签名:namespace Solution { open Microsoft.Quantum.Primitive; open Microsoft.Quantum.Canon; operation Solve (q : Qubit, sign : Int) : () { body { // your code here } }} [samples]
**Definitions** Let $|\psi\rangle = \alpha |0\rangle + \beta |1\rangle$ be the initial state of a qubit, with $\alpha, \beta \in \mathbb{C}$ and $|\alpha|^2 + |\beta|^2 = 1$. Let $s \in \{ -1, 1 \}$ be an integer sign parameter. **Constraints** 1. $|\alpha|^2 + |\beta|^2 = 1$ 2. $s = 1$ or $s = -1$ **Objective** Apply a unitary operation such that the final state of the qubit is: $$ |\psi_{\text{final}}\rangle = \begin{cases} |0\rangle & \text{if } s = 1 \\ |1\rangle & \text{if } s = -1 \end{cases} $$
API Response (JSON)
{
  "problem": {
    "name": "A. Generate plus state or minus state",
    "description": {
      "content": "You are given a qubit in state and an integer _sign_. Your task is to convert the given qubit to state if _sign_ = 1 or if _sign_ =  - 1.",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF1001A"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You are given a qubit in state and an integer _sign_.\n\nYour task is to convert the given qubit to state if _sign_ = 1 or if _sign_ =  - 1.\n\n## Input\n\nYou have to implement an operation which takes a q...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "给定一个处于状态  的量子比特和一个整数 #cf_span[sign]。\n\n你的任务是:如果 #cf_span[sign = 1],将该量子比特转换为状态 ;如果 #cf_span[sign =  - 1],将其转换为状态 。\n\n你需要实现一个操作,该操作以一个量子比特和一个整数作为输入,且无输出。你的解决方案的“输出”是其作用后量子比特所处的状态。\n\n你的代码应具有以下签名:\n\n## Input...",
      "is_translate": true,
      "language": "Chinese"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $|\\psi\\rangle = \\alpha |0\\rangle + \\beta |1\\rangle$ be the initial state of a qubit, with $\\alpha, \\beta \\in \\mathbb{C}$ and $|\\alpha|^2 + |\\beta|^2 = 1$.  \nLet $s \\in \\{ -1, 1 \\...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments