CF1217C.The Number Of Good Substrings
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given a binary string s (recall that a string is binary if each character is either 0 or 1 ).
Let f(t) be the decimal representation of integer t written in binary form (possibly with leading zeroes). For example f(011)=3,f(00101)=5,f(00001)=1,f(10)=2,f(000)=0 and f(000100)=4 .
The substring sl,sl+1,…,sr is good if r−l+1=f(sl…sr) .
For example string s=1011 has 5 good substrings: s1…s1=1 , s3…s3=1 , s4…s4=1 , s1…s2=10 and s2…s4=011 .
Your task is to calculate the number of good substrings of string s .
You have to answer t independent queries.
输入格式
The first line contains one integer t ( 1≤t≤1000 ) — the number of queries.
The only line of each query contains string s ( 1≤∣s∣≤2⋅105 ), consisting of only digits 0 and 1 .
It is guaranteed that i=1∑t∣si∣≤2⋅105 .
输出格式
For each query print one integer — the number of good substrings of string s .
输入输出样例
输入#1
4 0110 0101 00001000 0001000
输出#1
4 3 4 3