CF1731C.Even Subarrays
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given an integer array a1,a2,…,an ( 1≤ai≤n ).
Find the number of subarrays of a whose XOR has an even number of divisors. In other words, find all pairs of indices (i,j) ( i≤j ) such that ai⊕ai+1⊕⋯⊕aj has an even number of divisors.
For example, numbers 2 , 3 , 5 or 6 have an even number of divisors, while 1 and 4 — odd. Consider that 0 has an odd number of divisors in this task.
Here XOR (or ⊕ ) 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 t ( 1≤t≤104 ). Description of the test cases follows.
The first line of each test case contains a single integer n ( 2≤n≤2⋅105 ) — the length of the array a .
The second line contains n integers a1,a2,…,an ( 1≤ai≤n ).
It is guaranteed that the sum of n over all test cases does not exceed 2⋅105 .
输出格式
For each test case, print the number of subarrays, whose 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 4 subarrays whose XOR has an even number of divisors: [3] , [3,1] , [1,2] , [2] .
In the second test case, there are 11 subarrays whose XOR has an even number of divisors: [4,2] , [4,2,1] , [4,2,1,5] , [2] , [2,1] , [2,1,5] , [2,1,5,3] , [1,5,3] , [5] , [5,3] , [3] .
In the third test case, there is no subarray whose XOR has an even number of divisors since XOR of any subarray is either 4 or 0 .