#abc340c. C - Divide and Divide
C - Divide and Divide
Score: points
问题描述
在黑板上写有一个整数 。
Takahashi 将重复以下一系列操作,直到黑板上所有不小于 的整数都被移除:
- 选择一个黑板上书写的不小于 的整数 。
- 从黑板上擦去一个出现的 。然后,在黑板上写下两个新的整数 和 。
- Takahashi 执行这一系列操作需要支付 日元。
其中, 表示不大于 的最大整数,而 表示不小于 的最小整数。
当无法再进行操作时,Takahashi 累计支付的总金额是多少? 可以证明,无论操作的顺序如何,他将支付的总额是一个常数。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
There is a single integer written on a blackboard.
Takahashi will repeat the following series of operations until all integers not less than are removed from the blackboard:
- Choose one integer not less than written on the blackboard.
- Erase one occurrence of from the blackboard. Then, write two new integers and on the blackboard.
- Takahashi must pay yen to perform this series of operations.
Here, denotes the largest integer not greater than , and denotes the smallest integer not less than .
What is the total amount of money Takahashi will have paid when no more operations can be performed?
It can be proved that the total amount he will pay is constant regardless of the order in which the operations are performed.
Constraints
Input
The input is given from Standard Input in the following format:
Output
Print the total amount of money Takahashi will have paid, in yen.
Sample Input 1
3
Sample Output 1
5
Here is an example of how Takahashi performs the operations:
- Initially, there is one written on the blackboard.
- He chooses . He pays yen, erases one from the blackboard, and writes and on the blackboard.
- There is one and one written on the blackboard.
- He chooses . He pays yen, erases one from the blackboard, and writes and on the blackboard.
- There are three s written on the blackboard.
- Since all integers not less than have been removed from the blackboard, the process is finished.
Takahashi has paid a total of yen for the entire process, so print .
Sample Input 2
340
Sample Output 2
2888
Sample Input 3
100000000000000000
Sample Output 3
5655884811924144128
update @ 2024/3/10 01:32:47