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 เล่นทีหลัง: เธอต้องเลือกจำนวนเฉพาะ $p$ ที่หาร $n$ ปัจจุบันลงตัว (กล่าวคือ $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.