#P10411. 「QFOI R2」树色尤含残雨

    ID: 11709 远端评测题 1000ms 512MiB 尝试: 0 已通过: 0 难度: 5 上传者: 标签>数学贪心数论洛谷原创O2优化洛谷月赛

「QFOI R2」树色尤含残雨

Problem Description

Little R is a cute girl, and she likes prime factorization.

She has a positive integer xx. In each operation, you may choose p1,α1,p2,α2p_1, \alpha_1, p_2, \alpha_2 such that p1,p2p_1, p_2 are two different primes and α1,α2\alpha_1, \alpha_2 are positive integers. If xx is divisible by p1α1p2α2p_1^{\alpha_1} p_2^{\alpha_2}, then divide xx by p1α1p2α2p_1^{\alpha_1} p_2^{\alpha_2}; otherwise, the operation is invalid.

Please find the minimum possible value of xx that can be obtained after performing the operation some number of times.

Input Format

One line containing one integer xx.

Output Format

Output one integer, the minimum possible xx that can be obtained.

9
9
120
1
2310
2

Hint

Explanation for Sample 11

No valid operation can be performed.


Explanation for Sample 22

You can perform the following two operations:

  • Let p1=2,α1=1,p2=3,α2=1p_1 = 2, \alpha_1 = 1, p_2 = 3, \alpha_2 = 1. Divide xx by p1α1p2α2=2131=6p_1^{\alpha_1} p_2^{\alpha_2} = 2^1 3^1 = 6, obtaining x=20x = 20.
  • Let p1=2,α1=2,p2=5,α2=1p_1 = 2, \alpha_1 = 2, p_2 = 5, \alpha_2 = 1. Divide xx by p1α1p2α2=2251=20p_1^{\alpha_1} p_2^{\alpha_2} = 2^2 5^1 = 20, obtaining x=1x = 1.

Constraints

This problem uses bundled tests. You can only get the corresponding score if you pass all test points in a subtask and all subtasks it depends on.

For all data: 2x1092 \le x \le 10^9.

  • Subtask 1 (1010 points): x10x \le 10.
  • Subtask 2 (2020 points): xx is a "square-free number"^\dagger.
  • Subtask 3 (2020 points): xx is a positive integer power of a prime.
  • Subtask 4 (2020 points): x105x \le 10^5. Depends on Subtask 1.
  • Subtask 5 (3030 points): No special constraints. Depends on Subtasks 1, 2, 3, and 4.

\dagger A number xx is called a "square-free number" if and only if there does not exist an integer k>1k > 1 such that xx is divisible by k2k^2.

Translated by ChatGPT 5