CF1731C.Even Subarrays

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given an integer array a1,a2,,ana_1, a_2, \dots, a_n ( 1ain1 \le a_i \le n ).

Find the number of subarrays of aa whose XOR\operatorname{XOR} has an even number of divisors. In other words, find all pairs of indices (i,j)(i, j) ( iji \le j ) such that aiai+1aja_i \oplus a_{i + 1} \oplus \dots \oplus a_j has an even number of divisors.

For example, numbers 22 , 33 , 55 or 66 have an even number of divisors, while 11 and 44 — odd. Consider that 00 has an odd number of divisors in this task.

Here XOR\operatorname{XOR} (or \oplus ) denotes the bitwise XOR operation.

Print the number of subarrays but multiplied by 2022... Okay, let's stop. Just print the actual answer.

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt ( 1t1041 \leq t \leq 10^4 ). Description of the test cases follows.

The first line of each test case contains a single integer nn ( 2n21052 \leq n \leq 2 \cdot 10^5 ) — the length of the array aa .

The second line contains nn integers a1,a2,,ana_1, a_2, \dots, a_n ( 1ain1 \leq a_i \leq n ).

It is guaranteed that the sum of nn over all test cases does not exceed 21052 \cdot 10^5 .

输出格式

For each test case, print the number of subarrays, whose XOR\operatorname{XOR} has an even number of divisors.

输入输出样例

  • 输入#1

    4
    3
    3 1 2
    5
    4 2 1 5 3
    4
    4 4 4 4
    7
    5 7 3 7 1 7 3

    输出#1

    4
    11
    0
    20

说明/提示

In the first test case, there are 44 subarrays whose XOR\operatorname{XOR} has an even number of divisors: [3][3] , [3,1][3,1] , [1,2][1,2] , [2][2] .

In the second test case, there are 1111 subarrays whose XOR\operatorname{XOR} has an even number of divisors: [4,2][4,2] , [4,2,1][4,2,1] , [4,2,1,5][4,2,1,5] , [2][2] , [2,1][2,1] , [2,1,5][2,1,5] , [2,1,5,3][2,1,5,3] , [1,5,3][1,5,3] , [5][5] , [5,3][5,3] , [3][3] .

In the third test case, there is no subarray whose XOR\operatorname{XOR} has an even number of divisors since XOR\operatorname{XOR} of any subarray is either 44 or 00 .

首页