A Fenwick Tree Question
View as PDFSimple statement. You have a 1-indexed array with  integers, and you want to perform some 
 queries on it.
1 p x: change indexptox, where2 l r: perform the OR bitwise operation on all pairs fromltor, inclusive, then sum them3 l r: perform the AND bitwise operation on all pairs fromltor, inclusive, then sum them4 l r: perform the XOR bitwise operation on all pairs fromltor, inclusive, then sum them
Input Specification
The first line will contain  and 
, 
, 
.
The second line will contain  integers.
The next  lines will contain valid queries.
For 30% of the points, , 
.
Output Specification
For each query from 2 to 4, output the sum.
Sample Input 1
6 1
4 4 8 10 4 6
2 3 6
Sample Output 1
70
Explanatioin
For the query from  to 
, there are 
 pairs:
,
, 
, 
, 
, 
.
So the total sum is .
Comments