CF390C.Inna and Candy Boxes

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

The first line of the input contains three integers nn , kk and ww (1<=k<=min(n,10),1<=n,w<=105)(1<=k<=min(n,10),1<=n,w<=10^{5}) . The second line contains nn characters. If the ii -th box contains a candy, the ii -th character of the line equals 1, otherwise it equals 0.

Each of the following ww lines contains two integers lil_{i} and rir_{i} (1<=li<=ri<=n)(1<=l_{i}<=r_{i}<=n) — the description of the ii -th question. It is guaranteed that rili+1r_{i}-l_{i}+1 is divisible by kk .

输入格式

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.

首页