OR Sum

4.5

2 votes
Basic Programming, Bit manipulation, Basics of Bit Manipulation, Easy, maths, Bit Manipulation
Problem

Given an array A[] of N numbers. Now, you need to find and print the Summation of the bitwise OR of all possible subsets of this array.

As answer can be large, print it Modulo 109+7

Input:


The first line contains a single integer T denoting the number of test cases in a single test file. 

The first line of each test case contains a number N denoting the number of elements in the given array. 

The second line contains the N elements of the array.

Output:

For each test case output a single number denoting the Summation of bitwise OR of all possible subsets of the given array.

Input Constraints:

1T101N1051A[i]109

Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

For [1, 2, 3], all possible subsets are {1}, {2}, {3}, {1,2}, {1,3}, {2,3}, {1,2,3}

The sum of OR of these subsets are, 1 + 2 + 3 + 3 + 3 + 3 + 3 = 18.

So, the answer would be 18.

Editor Image

?