spoj#YAXS. Yet Another Xor Sequence
Yet Another Xor Sequence
Fizz have an array A of n integers which ranges between [1,5] inclusive. Let f(i) denote number of times i occurs in the array.
Fizz wants to maximize the value of max(f(1),f(2),f(3),f(4),f(5)). To achieve it, he can perform one operation in the array as many time as he likes.
In each step Fizz can choose two integers Ai and Aj such that:
-
i!=j
-
1<=(Ai ⊕ Aj )<=5 [⊕ is the symbol for bitwise xor]
After choosing the integers, Fizz will remove them from the array and he will insert a new element (Ai ⊕ Aj ).
Fizz is very good in cricket but not so in programming, so please help him to find the maximum possible value of max(f(1),f(2),f(3),f(4),f(5)).
Input Format:
First line will contain an integer T(1<=T<=3000) denoting number of testcases. Each test case will contain two lines. First line will consist n(1<=n<=1000 ) and second line will consist n space separated integers between 1 to 5.
Output Format:
For each case, print the case number and the expected answer.
Sample Input:
1
8
2 3 4 2 3 5 1 2
Sample Output
Case 1: 5