##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
2 5 1 2 3 4 5 3 3 3 3
Basic example: First test has mixed values, second has all 3s. For all 3s, only lengths divisible by 3 count (length 3), giving answer 1.
10 1
4 1 1 2 1 1 3 2 2 2 4 1 2 4 8
Edge cases: n=1 with value 1 (answer=1 since 1|1), all 1s (all segments valid), all 2s (lengths 2,4,... divisible by 2), powers of 2 (AND decreases rapidly).
1 3 2 7
6 2 1 1 2 1 2 2 2 2 2 3 5 2 8 4 2 7 1
3 2 1 1 1 2
Rayan discovered ancient runes arranged in a row. Each rune has a power level .
A contiguous segment is called harmonious if its bitwise AND divides its length:
Count the total number of harmonious segments.
Note: does not divide any positive integer.
The first line contains the number of test cases ().
For each test case:
The sum of over all test cases does not exceed .
For each test case, print the number of harmonious segments.