Alice has \(N\) apples in a straight line. The \(i^{th}\) apple has the tastiness value of \(A[i]\), where \(0 <= i < N\). In one operation, you can do any of the following operations.
- You can choose apple at any position \(i\), \(0 <= i < N\). If its tastiness value \(A[i]\) is divisible by 2, divide \(A[i]/2\).
- You can choose apple at any position \(i\), \(0 <= i < N\). If its tastiness value \(A[i]\) is divisible by 3, divide \(A[i]/3\).
Alice gives you the task of making the tastiness value of all apples equal. Print \(Yes\) if you can complete the task, else print \(No\).
Input Format:
- The first line contains an integer \(T\), denoting the number of test cases.
- The first line of each test case contains \(N\), denoting the size of the array \(A\).
- The second line of each test case contains \(N\) space-separated integers denoting the elements of the array \(A\).
Output Format:
For each test case, print \(Yes\) if you can complete the task, else print \(No\).
Constraints:
\(1 <= T <= 10\)
\(1 <= N <= 10^5\)
\(0 <= A[i] <= 10^9\)
First test case:
In the first operation, choose apple at index \(2\). Divide its tastiness value by \(2\). So, \(A[2]\) will now be \(1\). In the second operation, choose apple at index \(3\). Divide its tastiness value by \(2\). So, \(A[3]\) will now be \(1\). The array \(A\) becomes \([1,1,1,1]\). Hence, the answer is \(Yes\).
Second test case:
It is not possible to make the tastiness value of all apples equal. Hence, the answer is \(No\).
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor
Loading...
Please wait while we load the editor