#P9473. [yLOI2022] 西施江南

[yLOI2022] 西施江南

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”.

Problem Description

Given nn positive integers a1,a2,a3,ana_1, a_2, a_3, \dots a_n, let gg be the greatest common divisor of these numbers, and let ll be the least common multiple of these numbers. Please determine whether l×gl \times g is equal to a1×a2××ana_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 TT, 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 nn, indicating the number of integers.
The second line of each group contains nn integers, where the ii-th integer is aia_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 Yes\texttt{Yes}.
  • Otherwise, output No\texttt{No}.
3
2
2 3
3
2 3 4
3
3 8 35
Yes
No
Yes
见附加文件中的 C2.in
见附加文件中的 C2.ans

Hint

Constraints

Let NN denote the sum of nn within a single test point, i.e., N=nN = \sum n.

  • For 12%12\% of the data, it is guaranteed that n=2n = 2.
  • For 36%36\% of the data, it is guaranteed that n5n \leq 5.
  • For 52%52\% of the data, it is guaranteed that N1000N \leq 1000.
  • For 76%76\% of the data, it is guaranteed that N,ai105N, a_i \leq 10^5.
  • For 100%100\% of the data, it is guaranteed that 2n,N5×1052 \leq n, N \leq 5 \times 10^5, 2ai1082 \leq a_i \leq 10^8, 1T201 \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