問題一覧 > 通常問題

No.1372 Median of Submasks

レベル : / AI推定難易度 : 800 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 233
作問者 : leaf_1415 / テスター : wotsushi
お気に入りにしたユーザー ProblemId : 5302 / 自分の提出
問題文最終更新日: 2021-02-04 03:14:20
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 281 (順位表) の他の問題:

Problem Statement

You are given a positive integer $N$.
Define the set $S_N$ by $S_N := \{x \ | \ x \& N = x,\ x$ is a positive integer$\}$.
(Here, $\&$ denotes bitwise AND.)
Note that, by definition, $S_N$ does not contain $0$.

It can be shown that the number of elements $|S_N|$ of $S_N$ is odd.
Print the median of $S_N$, that is, the $(|S_N|+1)/2$-th smallest value.

Input

$N$

$1 \leq N < 2^{60}$
$N$ is an integer.

Output

Print the median of $S_N$.
Print a newline at the end.

Sample

Sample 1
Input
5
Output
4

Since $S_5 = \{1, 4, 5\}$, the median of $S_5$ is $4$.

Sample 2
Input
1
Output
1

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