cswork / OA打开练习工作台

AmazonOA #126

Count Special Strings

估计困难可在线判题

考点(AI 标注)字符串前缀和区间位运算

Count the non-empty binary substrings in which the number of 0s equals the square of the number of 1s. Different index ranges are counted separately.

输入格式

One line with a 01 string of length 1..100000.

输出格式

Output a single integer answer.

样例 1

输入:

010001

输出:

4

样例 2

输入:

10010

输出:

3

样例 3

输入:

0

输出:

0

样例说明

Example 1: the three length-2 ranges 01, 01 and 10, plus the whole 010001, 4 in total. Example 2: three adjacent 01 or 10 ranges, 3 in total. Example 3: a single 0 does not satisfy 1=0², so the answer is 0.