CF390C.Inna and Candy Boxes
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
The first line of the input contains three integers n , k and w (1<=k<=min(n,10),1<=n,w<=105) . The second line contains n characters. If the i -th box contains a candy, the i -th character of the line equals 1, otherwise it equals 0.
Each of the following w lines contains two integers li and ri (1<=li<=ri<=n) — the description of the i -th question. It is guaranteed that ri−li+1 is divisible by k .
输入格式
For each question, print a single number on a single line — the minimum number of operations Dima needs to make the answer to the question positive.
输出格式
For the first question, you need to take a candy from the first box to make the answer positive. So the answer is 1.
For the second question, you need to take a candy from the first box, take a candy from the fifth box and put a candy to the sixth box. The answer is 3.
For the third question, you need to take a candy from the fifth box and put it to the sixth box. The answer is 2.
输入输出样例
输入#1
10 3 3 1010100011 1 3 1 6 4 9
输出#1
1 3 2
说明/提示
For the first question, you need to take a candy from the first box to make the answer positive. So the answer is 1.
For the second question, you need to take a candy from the first box, take a candy from the fifth box and put a candy to the sixth box. The answer is 3.
For the third question, you need to take a candy from the fifth box and put it to the sixth box. The answer is 2.