You are given an integer array
Let
See sample for a better explanation.
If it is possible to do for any element, print 1. Otherwise, print 0.
Input format
- The first line contains
denoting the number of test cases. - The first line of each test case contains an integer
denoting the number of elements in array . - The second line of each test case contains
space-separated integers of array .
Output format
For each test case, print a single line of
Constraints
Let us consider answers for each index:
1st index: If we choose subset {1} of the array we know 12 =1 so answer for this index is 1 because element at this index 1 can be expressed. Note that we could also choose higher power.
2nd index: If we choose subset {3,5} of the array we know 23 =8 so answer for this index is 1.
Note that we could also choose power 2 and have set {4} or {1,3}.
3rd index: If we choose subset {1,8} of the array we know 32 =9 so answer for this index is 1.
8th index: There is no subset of array which equals 82,83 or higher powers so answer for this case is 0.
Please login to use the editor
You need to be logged in to access the code editor
Login to unlock the editorial
Please login to use the editor
You need to be logged in to access the code editor