01string
题号:NC245376
时间限制:C/C++/Rust/Pascal 2秒,其他语言4秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

A string s0 is given, only consisting of 0 and 1. The j-th character of the string si is si,j , when the index starts from 0. We defifine si (i ≥ 1) as follows:
The length of si is less than the length of si−1 by 1. And for each letter si,j in the string si ,
si,j = max(si−1,j , si−1,j+1).
For example, if s0 = 1010, then s1 = 111, s2 = 11, etc.
f(s) represents the number of 1 in the string s. Please print the result of .

输入描述:

The fifirst line contains one integer t(1 ≤ t ≤ 105 ) — the number of test cases.
The fifirst line of each test case contains two integers n, and k (1 ≤ n ≤ 3 · 105 , 1 ≤ k ≤ n) — the length of s0 and the variable in .
The second line contains the string s0 — the original string mentioned above.
It is guaranteed that the sum of n over all test cases does not exceed 3 · 105 .

输出描述:

For each test case print one integer — the result of .
示例1

输入

复制
3
4 3
0011
4 2
0011
4 1
0011

输出

复制
7
6
4