fork download
  1. test = int(input())
  2. for t in range(test):
  3. n , k = map(int,input().split())
  4. s = input()
  5. lastone = -1
  6. count = 0
  7.  
  8. for i in range(n):
  9. if int(s[i])==1:
  10. if lastone>=max(0,i-k+1) and lastone<=i-1:
  11. count+=1
  12. lastone = i
  13. else:
  14. continue
  15. print(count)
  16.  
  17.  
  18.  
Success #stdin #stdout 0.11s 14120KB
stdin
9
2 2
11
6 6
100001
5 3
10000
7 2
1010101
7 4
0000001
3 3
010
3 2
011
7 4
1001001
8 3
00000000
stdout
0
0
0
0
0
0
0
0
0