#### Loading...

Form a number divisible by 3 using array digits
Easy Accuracy: 60.02% Submissions: 4422 Points: 2

Given an array of integers, the task is to find whether it’s possible to construct an integer using all the digits of these numbers such that it would be divisible by 3. If it is possible then print “1” and if not print “0”.

Input:
The first line consists of an integer T i.e. the number of test cases. First line of each test case consist of an integer n. Next line consists of n spaced integers.

Output:
Print '1' if it is possible to form a number divisible by 3 using the array elements otherwise print '0'.

Constraints:
1 <= T <= 100
1 <= n,a[i] <= 105

Examples:
Input :

2
3
40 50 90
2
1 4

Output :
1
0

Explanation :
Input : arr[] = {40, 50, 90} Output : Yes We can construct a number which is divisible by 3, for example 945000. So the answer is Yes. Input : arr[] = {1, 4} Output : No The only possible numbers are 14 and 41, but both of them are not divisible by 3, so the answer is No.

to report an issue on this page.

### Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

#### My Submissions:

Login to access your submissions.