题意: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 yinclusively.
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).
思路:这个题其实就可以转化为求区间的个数,其中区间内1的个数为奇数,其实思路还是挺好转化的,但是个人感觉代码写起来技巧性还是很强的。
先根据输入的串s求出区间内1个数的奇偶(根据异或),然后在倒着统计有奇数个1的区间个数,偶数个1的区间个数,最后统计总区间个数,在统计总区间个数的时候注意统计方法,同时注意对字符串的处理方式还有计数方式。
#include
#include
#include
#include
#include
#include