問題一覧 > 通常問題

No.1737 One to N

レベル : / AI推定難易度 : 600 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 229
作問者 : Shirotsume / テスター : nok0 とりゐ
お気に入りにしたユーザー ProblemId : 6461 / 自分の提出
問題文最終更新日: 2022-07-20 02:04:19
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 322 (順位表) の他の問題:

Problem Statement

You have an integer $X$. Initially, $X = 1$.

You may perform the following operation on the integer $X$ any number of times, possibly $0$ times.

    Operation: Choose $1$ integer that is at least $2$, and let $K$ be the chosen integer. Pay $K$ yen and replace $X$ with $KX$.

Given a positive integer $N$, find the minimum amount of money required to make $X = N$.

Constraints

  • $ 1 \leq N \leq 3 \times 10^5$
  • $N$ is an integer.

Input

The input is given from Standard Input in the following format.
$N$

Output

Output the minimum amount of money required. Print a newline at the end.

Sample

Sample 1
Input
12
Output
7

Initially, $X = 1$. If you choose $K = 3$ in the $1$st operation, you pay $3$ yen and $X$ is replaced with $3 \times 1 = 3$.

If you choose $K = 4$ in the $2$nd operation, you pay $4$ yen and $X$ is replaced with $4 \times 3 = 12$.

With the above procedure, you can make $X = N$ by paying a total of $7$ yen. There is no procedure that makes $X = N$ for less than $7$ yen, so output $7$.

Sample 2
Input
123456
Output
658

Sample 3
Input
1
Output
0

Since $X = 1$ from the start, you do not need to pay any money.

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