F. Xorro the Xorman

Codeforces
IDCF10278F
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
Erik forgot to make a costume for this year's Halloween festivities, which means he has to reuse his old Zorro outfit from last year. However, he doesn't want to be ridiculed by his friends for his laziness, so Erik rebrands himself as Xorro the Xorman. Instead of slashing a 'Z' on his enemies defeated in sword combat, Xorro will carve an 'X' onto whomever cannot answer his question involving the XOR bitwise operator. You meet the infamous Xorman while trick or treating, and are given two integers $A$ and $B$. Xorro wants you to tell him the maximum possible XOR of $A$ and $b$ for some integer $0 <= b <= B$. If you fail to answer correctly, Erik will strike in retaliation. Can you avoid the wrath of Xorro? The first and only line of input contains two integers $A$ and $B$ such that $0 <= A, B <= 10^(18)$. Output a single integer representing the answer to Xorro's query, the maximum possible value of $A plus.circle b$. ## Input The first and only line of input contains two integers $A$ and $B$ such that $0 <= A, B <= 10^(18)$. ## Output Output a single integer representing the answer to Xorro's query, the maximum possible value of $A plus.circle b$. [samples]
**Definitions** Let $ A, B \in \mathbb{Z} $ with $ 0 \le A, B \le 10^{18} $. **Constraints** $ 0 \le B $, and we seek $ b \in \mathbb{Z} $ such that $ 0 \le b \le B $. **Objective** Maximize the XOR value: $$ \max_{\substack{b \in \mathbb{Z} \\ 0 \le b \le B}} (A \oplus b) $$
API Response (JSON)
{
  "problem": {
    "name": "F. Xorro the Xorman",
    "description": {
      "content": "Erik forgot to make a costume for this year's Halloween festivities, which means he has to reuse his old Zorro outfit from last year. However, he doesn't want to be ridiculed by his friends for his la",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10278F"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Erik forgot to make a costume for this year's Halloween festivities, which means he has to reuse his old Zorro outfit from last year. However, he doesn't want to be ridiculed by his friends for his la...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ A, B \\in \\mathbb{Z} $ with $ 0 \\le A, B \\le 10^{18} $.  \n\n**Constraints**  \n$ 0 \\le B $, and we seek $ b \\in \\mathbb{Z} $ such that $ 0 \\le b \\le B $.  \n\n**Objective**  \nMaximi...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments