XOR Sum 3
InterviewTime limit2sMemory limit512 MB
Compute the XOR of every contiguous subsequence of A and print the sum of all those XOR values.
- Level
Medium6 of 10
- Topics
- Bit manipulation, Prefix sum, Math
- Solved
- No attempts yet
Problem
The XOR sum of a sequence is the value obtained by XORing all of its elements together.
Given a sequence , write a program that computes the XOR sum of every contiguous subsequence of and outputs the total of all those XOR sums.
Input
The first line contains the length of the sequence.
The second line contains the elements of , separated by spaces. Each element is a non-negative integer not exceeding .
Output
Print the sum of the XOR sums of all contiguous subsequences of on the first line.