The meaning of the question is an array of integers a 1, a 2, a 3,... An a_1,a_2,a_3,...a_na1,a2,a3,...an,定义 S ( i , j ) = a i + a i + 1 + a i + 2 + . . . + a j S(i,j)=a_i+a_{i+1}+a_{i+2}+...+a_j S(i,j)=ai+ai+1+ai+2+...+aj 求 ∑ i = 1 n ∑ j = i n ( ⌊ l o g 2 S ( i , j ) ⌋ + 1 ) ∗ ( i + j ) \sum_{i=1}^n\sum_{j=i}^n(\lfloor log_2S(i,j)\rfloor+1)*(i+j) ∑i=1n∑j=in(⌊log2S(i,j)⌋+1)∗(i+j ) Speciallog 2 0 = 0 log_20=0log20=0
Idea This question has a little trick, ⌊ log 2 N ⌋ + 1 \lfloor log_2N\rfloor+1⌊log2N⌋+1 is actually the number of binary digits of N. For this question, the maximum value of S is 1e5*1e5=1e10, so (⌊ log 2 S (i, j) ⌋ + 1 (\lfloor log_2S(i,j)\rfloor+1(⌊log2S(i,j)⌋+The maximum value of 1 is 34. We can first enumerate the number of digits, then enumerate i, and finally use the ruler method to find the range of j (l, r);