#P8469. [Aya Round 1 D] 文文的数学游戏
[Aya Round 1 D] 文文的数学游戏
Background
After solving the previous problem, Cirno felt as if she were a genius. So, Shameimaru Aya gave her another simple math problem.
Problem Description
Given an integer sequence of length , you need to construct an integer sequence of length such that for all , we have . Also, should be as large as possible, where denotes the greatest common divisor. Find the maximum possible value and, when this maximum is achieved, the number of different sequences , modulo .
Two sequences of length are considered different if and only if there exists an integer such that .
Input Format
- The first line contains an integer .
- The second line contains integers, representing the sequence .
Output Format
- Output one line with two integers: the maximum that can be obtained, and the number of corresponding different sequences achieving this maximum, modulo .
3
1 2 3
1 6
Hint
Sample 1 Explanation
Note that since , must be . Therefore, the maximum possible value can only be . Under this condition, all valid are as follows:
- $\{1,1,1\},\{1,1,2\},\{1,1,3\},\{1,2,1\},\{1,2,2\},\{1,2,3\}$.
Constraints
For of the testdata, , .
This problem comes with a set of large samples.
Translated by ChatGPT 5