P9473 [yLOI2022] Xishi Jiangnan
Background
> When I face Jiangnan, it is like meeting Xishi’s face.
> A clear fragrance should be sent to the shore; lotus flowers are before the fresh rain.
> Bright wrists part the pearl curtains; pearl dew stirs the waves, and the pearls and jade gather in.
> A natural scene of meeting and parting; she once spoke with a gentle smile.
> The tracks on the flat grass are still shallow; without rhyme it turns into lake fields.
> Though the gardens and woods are crafted and classical, that lovely figure cannot be embedded.
> Who can crown the poems? The long streets are dim; layer after layer of gates are closed.
> It seems there are soft hands遮目 (zhe mu) covering the eyes; in the empty valley, only the tiptoes remain.
Yin Lin, “Xishi Jiangnan”.
Description
Given $n$ positive integers $a_1, a_2, a_3, \dots a_n$, let $g$ be the **greatest common divisor** of these numbers, and let $l$ be the **least common multiple** of these numbers. Please determine whether $l \times g$ is equal to $a_1 \times a_2 \times \dots \times a_n$.
Input Format
**This problem contains multiple groups of testdata within a single test point.**
The first line contains an integer $T$, which represents the number of testdata groups. For each group, the input format is as follows:
The first line of each group contains an integer $n$, indicating the number of integers.
The second line of each group contains $n$ integers, where the $i$-th integer is $a_i$.
Output Format
For each group, output one line with a string representing the answer.
- If $l \times g = a_1 \times a_2 \times \dots \times a_n$, output $\texttt{Yes}$.
- Otherwise, output $\texttt{No}$.
Explanation/Hint
### Constraints
Let $N$ denote the sum of $n$ within a single test point, i.e., $N = \sum n$.
- For $12\%$ of the data, it is guaranteed that $n = 2$.
- For $36\%$ of the data, it is guaranteed that $n \leq 5$.
- For $52\%$ of the data, it is guaranteed that $N \leq 1000$.
- For $76\%$ of the data, it is guaranteed that $N, a_i \leq 10^5$.
- For $100\%$ of the data, it is guaranteed that $2 \leq n, N \leq 5 \times 10^5$, $2 \leq a_i \leq 10^8$, $1 \leq T \leq 20$.
### Hint
**There are millions of testdata; clear the first one first.**
**If you do not clear for multiple tests, two lines of tears for a zero score.**
**If clearing is not done properly, TLE will always follow.**
Translated by ChatGPT 5