Hard Divide and Conquer > Dynamic Programming

As you know, **Bunty** loves playing with numbers. He is now playing a game with his sister. Initially there is an array of N integers. They play the game in turns. **Bunty gives the first move**. In each move, one can choose two numbers from the array and score of this turn is the xor of the two numbers. After each turn, player removes the selected two integers from the array. The game continues until the array is empty. Now Bunty wants to know , what is the maximum score he can obtain. Note: Both of them play optimally well i.e Bunty's sister always plays in such a way that will make score of Bunty lesser and Bunty tries to maximize his score as much as possible. The Final Score of Bunty is the sum of all round played by Bunty Input: ------ Input starts with an integer **T (1<=20)**, denoting the number of test cases. Each case contains an integer **N ( 2≤ N ≤ 16)** denoting the number of elements of array A. N will be always even. Then in the next line there are N non-negative integers **(0 <= Ai <= 10^9)** Output: ------- For every test case, output the maximum score Bunty can obtain if both play optimally. Sample Input ------------ 1 4 1 2 4 3 Sample Output ------------- 7

Kazi Sohan