Issued a turtle's voice
We put all the sub-segments and XOR up
This routine thing together is the prefix Canadian Bitwise consider chant
First, prefixes and allows us to get \ (n ^ 2 \) The \ (20 \) points
Then consider bit, we found that as long as the calculation of \ (k \) on a bit \ (1 \) the number of occurrences
Strictly speaking
So long as we know that every \ (1 \) parity number of occurrences of
Because the subtraction will carry, so to consider the
We set \ (s [i] _k \ ) represents the \ (K \) bits are \ (0/1 \) , \ (S [I]. 1 ~ _ {K} \) represents \ (s [i] \ ) from the first \ (1 \) bit to \ () K \ magnitude bits
If \ (s [i] \) of \ (K \) bits are \ (1 \) , then the situation is contributing answers
\(1.s[j]_k=0\)且\(s[j]_{1~k-1}<=s[i]_{1~k-1}\)
\(2.s[j]_k=1\)且\(s[j]_{1~k-1}>s[i]_{1~k-1}\)
If \ (0 \)
\(1.s[j]_k=1\)且\(s[j]_{1~k-1}<=s[i]_{1~k-1}\)
\(2.s[j]_k=0\)且\(s[j]_{1~k-1}>s[i]_{1~k-1}\)
Found \ (\ sum a [i] \) is relatively small, considering opening two weights Fenwick tree, save the current bit is \ (0/1 \) when a \ (s [i] _ { 1 ~ k} \) the number of values
Method Two: God fish polynomial Technology
Set \ (F_i \) is the number of occurrences of each number, \ (S_I \) prefix and \ (I \) number of occurrences, \ (m = \ A SUM [I] \)
Then
\(f_i=\sum\limits_{j=0}^{m-i}s_j*s_{j+i}\)
Deform it
\(f_{m-i}=\sum\limits_{j=0}^{i}s_j*s_{m-i+j}\)
The right side of this thing looks quite like convolution. . We roll it about to get \ (f \) array flip
Then see which numbers are slightly different or even times up