Chef In Infinite Plane solution codechef
Chef has an integer sequence. For each index ( ), Chef needs to divide into two positive integers and such that , then place this as a point in the infinite -dimensional coordinate plane. Help Chef to find the maximum number of distinct points that can be put in the plane, if he optimally splits the values . Note that Chef can only perform one split for each index.
Note: Please use fast input/output methods for this problem.
- The first line contains a single integer – the number of test cases. The description of test cases follows.
- The first line of each test case contains a single integer .
- The second line contains integers .
For each test case, print a single line containing one integer — the maximum number of distinct points there can be in the infinite plane.
Sample Input 1
2 6 2 2 4 4 2 6 2 16 8
Sample Output 1
Test Case 1: Chef can divideas , as , as , as , as , as . Ignoring duplicates, there are distinct points, which is the maximum possible.
Test Case 2: Chef can divideas , as .