The problem of “Beautiful Arrays” with C Source code

Google+ Pinterest LinkedIn Tumblr +

An array a is called beautiful if for every pair of numbers a_i, a_j, (i \neq j), there exists an a_k such that a_k = a_i * a_j. Note that k can be equal to i or j too.

Input

First line of the input contains an integer T denoting the number of test cases. T test cases follow. First line of each test case contains an integer n denoting number of elements in a. Next line contains n space separated integers denoting the array a.

Output

For each test case, output a single line containing “yes” or “no” (without quotes) corresponding to the answer of the problem.

Approach 1: Naive

 

Approach 2: Advanced

Results

 

GitLab Repository: https://gitlab.com/robotomy/c-beautiful-arrays

Problem found at : https://www.codechef.com/problems/ICPC16B

Share.

Leave A Reply