Alice and Apple
Practice
4.3 (3 votes)
C++
Basic math
Observation
Math
Problem
63% Success 400 Attempts 30 Points 2s Time Limit 256MB Memory 1024 KB Max Code

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.

  1. 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\).
  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\)

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

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
1 votes
Tags:
Medium
Points:30
Tags:
HiringOpenHiringOpenImplementationHiringMathematicsEasyBasic ProgrammingMathematicsMathematicsMathamatics
Points:30
4 votes
Tags:
C++MathSortingBasic Math