QOJ.ac

QOJ

시간 제한: 1.0 s 메모리 제한: 512 MB 총점: 100 해킹 가능 ✓

#18431. 質數遊戲

통계

Iroha 與 Kaguya 最近迷上了一種基於整數的數學遊戲。

最初,她們共有一個正整數 $n$。兩人輪流進行操作;一輪定義為 Iroha 與 Kaguya 各完成一次操作。在每一輪中:

  1. Iroha 先手:她必須選擇一個非負整數 $x$($0\le x<n$),並將當前的 $n$ 替換為 $n+x$。

  2. Kaguya 後手:她必須選擇一個能整除當前 $n$ 的質數 $p$(即 $p\mid n$),並將當前的 $n$ 替換為 $\frac{n}{p}$。

上述操作不斷重複。如果在任意一輪結束後 $n=1$,遊戲立即結束。

遊戲中,Iroha 希望最大化遊戲進行的總輪數,而 Kaguya 希望最小化總輪數。假設兩人都完全理性且採用最佳策略,請確定遊戲最終會持續的總輪數。

輸入格式

第一行包含一個整數 $n$($1\le n\le10^{18}$),代表遊戲的初始數。

輸出格式

輸出一行,包含一個整數,代表雙方都採用最佳策略時遊戲持續的總輪數。

範例

範例輸入 1

1

範例輸出 1

0

範例輸入 2

9

範例輸出 2

4

範例輸入 3

16

範例輸出 3

5

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.