计蒜客 ACM-ICPC 2017 Asia Xi'an Sum of xor sum ()

网址:https://nanti.jisuanke.com/t/20755



  •  2000ms
  •  262144K

Song Zha Zha has an 11-indexed array A . Li Zha Zha has QQ queries . Each query has two integers LLRR , asking Ran Zha Zha to do the following thing .First , find all subintervals of [L,R][L,R] . Then calculate their xor sum . For example .

A={1,2,3}A=1,2,3 , L=1L=1R=3R=3.

All subintervals of [1,3][1,3] are [1,1],[2,2],[3,3],[1,2],[2,3],[3,3][1,1],[2,2],[3,3],[1,2],[2,3],[1,3] .Their xor sum = 1 + 2 + 3 + 11+2+3+1 xor 2 + 22+2 xor 3 + 13+1xor 22 xor 33 .

Xor means exclusive or . (^ in C++ or Java )

Input

The input contains multiple test cases.

First line contains an integer TT (1 \le T \le 10)(1T10) , which is the number of test cases .

In each test case:

The first line contains two integers NNQQ(1 \le N,Q \le 100000)(1N,Q100000) . NN is the length of the array AA .

Then one line contains NN integer indicating A[i]A[i](1 \le i \le N , 0 \le A[i] \le 1000000)(1iN,0A[i]1000000).

Then QQ lines follow . Each line two integer L,RL,R, means that there’s a query [L,R][L,R] . (1 \le L \le R \le N)(1LRN).

OutputFor each query, print the answer mod 10000000071000000007.

样例输入

1
3 1
1 2 3
1 3

样例输出

10

题目来源

ACM-ICPC 2017 Asia Xi'an


  •  2000ms
  •  262144K
  •  2000ms
  •  262144K

猜你喜欢

转载自blog.csdn.net/xigongdali/article/details/80443288