問題一覧 > 通常問題

No.3718 XOR Escape

レベル : / AI推定難易度 : 1775 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 1024 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 25
作問者 : ぽえ / テスター : kazuppa 👑 loop0919
お気に入りにしたユーザー ProblemId : 14043 / 自分の提出
問題文最終更新日: 2026-09-18 21:21:54
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 514 (順位表) の他の問題:

Problem Statement

You are given a positive integer $N$ and positive integers $A, B, C$ satisfying $A \oplus B \oplus C = 0$.

There is a variable $x$, initially $x = N$.

You may perform the following operation any number of times. Find the maximum possible number of times the operation can be performed.

  • Choose $1$ non-negative integer $y$ satisfying both $y \lt x$ and $x \oplus y \notin \{A, B, C\}$, and change the variable $x$ to $y$.

Here, $\oplus$ denotes bitwise $\mathrm{XOR}$.

Definition of bitwise $\mathrm{XOR}$ (click to expand) The bitwise $\mathrm{XOR}$ of non-negative integers $X, Y$, denoted $X \oplus Y$, is defined as follows.
  • The digit in the $2^k$ $(k \ge 0)$ place of $X \oplus Y$ in binary is $1$ if exactly one of the digits in the $2^k$ $(k \ge 0)$ place of $X, Y$ in binary is $1$, and $0$ otherwise.

Constraints

  • All input values are integers.
  • $1 \le N, A, B, C \le 10^{18}$
  • $A\oplus B\oplus C=0$

Input

The input is given from Standard Input in the following format.

$N$ $A$ $B$ $C$

Output

Output the answer.

Sample

Sample 1
Input
10 1 2 3
Output
2

For example, by changing $x$ as $10\to7\to3$, you can perform the operation $2$ times.

Sample 2
Input
20 10 13 7
Output
17

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。