Different summation

4.8

4 votes
Special Numbers, Medium, Ternary search, Algorithms, Searching algorithm, Mathematics, Counting
Problem

You have been given an array A of size N. Now, let's call the weight of a subsequence the xor of all elements it contains.The weight of a subsequence containing 0 elements is 0. Now, you need to find the summation of xor of each subsequence × the length of the subsequence over all 2N subsequences of the given array A.

As the answer can be rather large, print it Modulo 998244353

Can you do it ?

Input Format :

The first line contains a single integer N denoting the size of the given array A. The next line contains N integers, where the ith integer denotes A[i].

Output Format:

Print a single integer denoting the answer. As the answer can be rather large, print it Modulo 998244353

Input Constraints :

1N5105

0A[i]1018

Note that the Expected Output Feature for Custom Invocation is not supported for this contest. 

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

The sum is derived as 00+1(1+2)+2(12)=9

Editor Image

?