AtCoder Regular Contest 109
B
log
AtCoder
⌀ 524
原题
← AC →
翻译中…

Problem Statement

翻译中…

Snuke is visiting a shop in Tokyo called 109 to buy some logs. He wants $n$ logs: one of length $1$, one of length $2$, $...$, and one of length $n$. The shop has $n+1$ logs in stock: one of length $1$, one of length $2$, $\dots$, and one of length $n+1$. Each of these logs is sold for $1$ yen (the currency of Japan).

翻译中…

He can cut these logs as many times as he wants after buying them. That is, he can get $k$ logs of length $L_1, \dots, L_k$ from a log of length $L$, where $L = L_1 + \dots + L_k$. He can also throw away unwanted logs.

翻译中…

Snuke wants to spend as little money as possible to get the logs he wants. Find the minimum amount of money needed to get $n$ logs of length $1$ to $n$.

翻译中…

Constraints

翻译中…
  • $1 \leq n \leq 10^{18}$
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

n

翻译中…

Output

翻译中…

Print the minimum amount of money needed to get $n$ logs of length $1$ to $n$.

翻译中…

样例

Input #1
4
Output #1
3
One way to get the logs he wants with $3$ yen is: - Buy logs of length $2$, $4$, and $5$. - Cut the log of length $5$ into two logs of length $1$ each and a log of length $3$. - Throw away one of the logs of length $1$.
Input #2
109109109109109109
Output #2
109109108641970782
题目信息
题号
arc109_b
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。