300867: CF165C. Another Problem on Strings
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Another Problem on Strings
题意翻译
题意:给定k & 字符串s ,其中s是一个二进制字符串, $k\le10^6,|s|\le10^6$,输出s中包含k个1的子串的个数(我们认为两个子串不同当且仅当它们均非空并且它们出现的位置不同) CF题面提示(不看也行):在使用c/c++的scanf,printf时请使用%I64d输入long long,不要使用%lld(否则爆零查不出错后果自负)题目描述
A string is binary, if it consists only of characters "0" and "1". String $ v $ is a substring of string $ w $ if it has a non-zero length and can be read starting from some position in string $ w $ . For example, string "010" has six substrings: "0", "1", "0", "01", "10", "010". Two substrings are considered different if their positions of occurrence are different. So, if some string occurs multiple times, we should consider it the number of times it occurs. You are given a binary string $ s $ . Your task is to find the number of its substrings, containing exactly $ k $ characters "1".输入输出格式
输入格式
The first line contains the single integer $ k $ ( $ 0<=k<=10^{6} $ ). The second line contains a non-empty binary string $ s $ . The length of $ s $ does not exceed $ 10^{6} $ characters.
输出格式
Print the single number — the number of substrings of the given string, containing exactly $ k $ characters "1". Please do not use the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
输入输出样例
输入样例 #1
1
1010
输出样例 #1
6
输入样例 #2
2
01010
输出样例 #2
4
输入样例 #3
100
01010
输出样例 #3
0