You are given an array aa consisting of nn integers a1,a2,…,ana1,a2,…,an .
In one operation you can choose two elements of the array and replace them with the element equal to their sum (it does not matter where you insert the new element). For example, from the array [2,1,4][2,1,4] you can obtain the following arrays: [3,4][3,4] , [1,6][1,6] and [2,5][2,5] .
Your task is to find the maximum possible number of elements divisible by 33 that are in the array after performing this operation an arbitrary (possibly, zero) number of times.
You have to answer tt independent queries.
Input
The first line contains one integer tt (1≤t≤10001≤t≤1000 ) — the number of queries.
The first line of each query contains one integer nn (1≤n≤1001≤n≤100 ).
The second line of each query contains nn integers a1,a2,…,ana1,a2,…,an (1≤ai≤1091≤ai≤109 ).
Output
For each query print one integer in a single line — the maximum possible number of elements divisible by 33 that are in the array after performing described operation an arbitrary (possibly, zero) number of times.
Example
Input
Copy
2
5
3 1 2 3 1
7
1 1 1 1 1 2 2
Output
Copy
3
3
Note
In the first query of the example you can apply the following sequence of operations to obtain 33 elements divisible by 33 : [3,1,2,3,1]→[3,3,3,1][3,1,2,3,1]→[3,3,3,1] .
In the second query you can obtain 33 elements divisible by 33 with the following sequence of operations: [1,1,1,1,1,2,2]→[1,1,1,1,2,3]→[1,1,1,3,3]→[2,1,3,3]→[3,3,3][1,1,1,1,1,2,2]→[1,1,1,1,2,3]→[1,1,1,3,3]→[2,1,3,3]→[3,3,3] .
题意:问一组数据中最多合成几个能整除3的数。
思路:本来能整除的整除,不能整除的看余数,余数为1和余数为2的,3个余数为1的,3跟 余数为2的都可以合成一个。
AC代码
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
typedef long long ll;
#define MAX 1e5
int main()
{
ll q,i,j,ans=0,n,a,T;
cin>>T;
while(T--)
{
cin>>n;
ll sum=0,ans=0,y=0,z=0;
for(i=0;i<n;i++)
{
cin>>a;
if(a%3==0)
ans++;
else
if(a%3==1)
y++;
else
if(a%3==2)
z++;
}
//cout<<y<<"*"<<z<<endl;
if(y<=z)
{
ans+=y;
z-=y;
ans+=z/3;
}
else
{
ans+=z;
y-=z;
ans+=y/3;
}
cout<<ans<<endl;
}
return 0;
}