#C8147. Equal Page Stacks
Equal Page Stacks
Equal Page Stacks
You are given a series of test cases. In each test case, you are provided with the number of comic books and their respective page counts. Your task is to determine if these comic books can be arranged into stacks such that each stack has an equal number of pages. For a single comic book, output YES since it forms a valid stack by itself.
For multiple comic books, calculate the greatest common divisor (GCD) of all the page counts. The answer is YES if and only if the GCD is greater than 1, i.e. if there exists an integer \(d > 1\) such that \(d\) divides every page count; otherwise, output NO.
inputFormat
The input begins with an integer \(T\) representing the number of test cases. For each test case, the first line contains an integer \(N\) (the number of comic books), followed by a line with \(N\) space-separated integers representing the page counts of each comic book.
outputFormat
For each test case, output a single line containing \(YES\) if the comic books can form stacks with equal pages (i.e. if the GCD of the page counts is greater than 1 or there is only one book), and \(NO\) otherwise.
## sample1
1
5
YES
</p>