問題一覧 > 通常問題

No.378 Let's Earn Fame Points

レベル : / AI推定難易度 : 550 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 489
作問者 : LayCurse / テスター : 37zigen
お気に入りにしたユーザー ProblemId : 922 / 自分の提出
問題文最終更新日: 2026-06-25 05:26:13
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 139 (順位表) の他の問題:

Problem Statement

Quests in a certain game can be cleared any number of times, and clearing a quest earns you fame points.
A certain quest in that game gives $N$ fame points on the first clear, and the fame points earned are halved (rounded down) with each clear.
That is, if the fame points earned on the first clear are $12$, the fame points earned on the $1$st, $2$nd, … clears are $12, 6, 3, 1, 0, 0, \ldots$.
Thus, you can earn a total of $12 + 6 + 3 + 1 = 22$ fame points.

However, if you clear the quest using a character who has a certain skill, the fame points earned are doubled, but in exchange the fame points earned on subsequent clears become $0$.
For example, if you clear normally the $1$st time and clear using that character the $2$nd time, the fame points earned are $12 + 2 \times 6 + 0 + 0 + \cdots = 24$.

Write a program that finds the maximum number of extra fame points you can earn by making good use of the character with the skill, compared to never using that character.

Input

$N$

$1 \leq N \leq 10^{18}$

Output

Output the maximum number of extra fame points you can earn.

Sample

Sample 1
Input
12
Output
2

This is the example given in the statement.
If you keep clearing normally, you earn $22$ fame points, but with good play you can earn $24$ fame points, so the answer is $24-22 = 2$.

Sample 2
Input
123456789123456789
Output
31

Note that the input does not fit in a $32$-bit integer type.

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