No.1372 Median of Submasks
問題文最終更新日: 2021-02-04 03:14:20
English (AI translation)
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もしくは右上の雲マークをクリックしてアカウントを作成してください。
leaf_1415
wotsushi