A. Sherlock Bones
题目描述
The great dog detective Sherlock Bones is on the verge of a new discovery. But for this problem, he needs the help of his most trusted advisor -you- to help him fetch the answer to this case.
He is given a string of zeros and ones and length N.
Let F(x, y) equal to the number of ones in the string between indices x and y inclusively.
Your task is to help Sherlock Bones find the number of ways to choose indices (i, j, k) such that i < j < k, sj is equal to 1, and F(i, j) is equal to F(j, k).
输入
The first line of input is T – the number of test cases.
The first line of each test case is an integer N (3 ≤ N ≤ 2 × 105).
The second line is a string of zeros and ones of length N.
输出
For each test case, output a line containing a single integer- the number of ways to choose indices (i, j, k).
样例
inputCopy
3
5
01010
6
101001
7
1101011
outputCopy
2
3
7
题意
AC代码
这里写代码片