AtCoder Beginner Contest 153
翻译中…
Problem Statement
翻译中…
Caracal is fighting with a monster.
翻译中…
The health of the monster is $H$.
翻译中…
Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens:
翻译中…
- If the monster's health is
$1$, it drops to$0$. - If the monster's health,
$X$, is greater than$1$, that monster disappears. Then, two new monsters appear, each with the health of$\lfloor X/2 \rfloor$.
翻译中…
($\lfloor r \rfloor$ denotes the greatest integer not exceeding $r$.)
翻译中…
Caracal wins when the healths of all existing monsters become $0$ or below.
翻译中…
Find the minimum number of attacks Caracal needs to make before winning.
翻译中…
Constraints
翻译中…
$1 \leq H \leq 10^{12}$- All values in input are integers.
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
H
翻译中…
Output
翻译中…
Find the minimum number of attacks Caracal needs to make before winning.
翻译中…
样例
Input #1
2
Output #1
3
When Caracal attacks the initial monster, it disappears, and two monsters appear, each with the health of $1$.
Then, Caracal can attack each of these new monsters once and win with a total of three attacks.
Input #2
4
Output #2
7
Input #3
1000000000000
Output #3
1099511627775
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。