A. Remainder Codeforces Round #560 (Div. 3)

You are given a huge decimal number consisting of nn digits. It is

guaranteed that this number has no leading zeros. Each digit of this

number is either 0 or 1.

You may perform several (possibly zero) operations with this number.

During each operation you are allowed to change any digit of your

number; you may change 0 to 1 or 1 to 0. It is possible that after

some operation you can obtain a number with leading zeroes, but it

does not matter for this problem.

You are also given two integers 0≤y<x<n0≤y<x<n. Your task is to

calculate the minimum number of operations you should perform to

obtain the number that has remainder 10y10y modulo 10x10x. In other

words, the obtained number should have remainder 10y when divided by

10x.

Input

The first line of the input contains three integers n,x,y

(0≤y<x<n≤2⋅1050≤y<x<n≤2⋅105) — the length of the number and the

integers x and y, respectively.

The second line of the input contains one decimal number consisting of

n digits, each digit of this number is either 0 or 1. It is guaranteed

that the first digit of the number is 1.

Output

Print one integer — the minimum number of operations you should

perform to obtain the number having remainder 10的y次幂 modulo 10的x次幂. In

other words, the obtained number should have remainder 10的y次幂 when

divided by 10的x次幂.

Examples

input

Copy

11 5 2
11010100101
output Copy 1
input Copy 11 5 1
11010100101
output Copy 3

Note

In the first example the number will be 1101010010011010100100 after

performing one operation. It has remainder 100100 modulo 100000100000.

In the second example the number will be 1101010001011010100010 after

performing three operations. It has remainder 1010 modulo

100000100000.

题解如下

#include<iostream>
#include<string.h>
using namespace std;
const int Len = 5e5;
char ar[Len]; int main()
{
//freopen("test.txt","r",stdin);
int n,x,y;
scanf("%d %d %d",&n,&x,&y);
scanf("%s",ar + 1);
int ans = 0;
for(int i = n - x + 1; i <= n; i ++) //在[n-x+1,n] 这个区间内的数字进行一一讨论,如果与当前位 的数字不是自己想要的 ans ++
{
if(i < n - y)
{
if(ar[i] != '0')
ans ++;
}
else if(i == n - y)
{
if(ar[i] != '1')
ans ++;
}
else
{
if(ar[i] != '0')
ans ++;
}
}
printf("%d",ans); return 0;
}

A. Remainder Codeforces Round #560 (Div. 3)的更多相关文章

  1. Codeforces Round #560 (Div. 3) Microtransactions

    Codeforces Round #560 (Div. 3) F2. Microtransactions (hard version) 题意: 现在有一个人他每天早上获得1块钱,现在有\(n\)种商品 ...

  2. Codeforces Round #560 Div. 3

    题目链接:戳我 于是...风浔凌弱菜又去写了一场div.3 总的来说,真的是比较简单.......就是.......不开long long见祖宗 贴上题解-- A 给定一个数,为01串,每次可以翻转一 ...

  3. Codeforces Round #560 (Div. 3)A-E

    A. Remainder output standard output You are given a huge decimal number consisting of nn digits. It ...

  4. Codeforces Round #277 (Div. 2) 题解

    Codeforces Round #277 (Div. 2) A. Calculating Function time limit per test 1 second memory limit per ...

  5. Codeforces Round #422 (Div. 2)

    Codeforces Round #422 (Div. 2) Table of Contents Codeforces Round #422 (Div. 2)Problem A. I'm bored ...

  6. Codeforces Round #272 (Div. 2) 题解

    Codeforces Round #272 (Div. 2) A. Dreamoon and Stairs time limit per test 1 second memory limit per ...

  7. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  8. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  9. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

随机推荐

  1. Flutter环境搭建以及快捷命令

    Flutter环境搭建 配置环境变量 用户变量 FLUTTER_STORAGE_BASE_URL : https://storage.flutter-io.cn PUB_HOSTED_URL : ht ...

  2. javascript入门进阶(一)

    javascript 入门进阶 这里主要讲解一下在入门阶段很难注意的一些知识点,不一定有用.但是会了总比不会强. 1.HTML为<script>标签准备的6个属性: -async:可选.表 ...

  3. Block as a Value for SQL over NoSQL

    作者 Yang Cao,Wenfei Fan,Tengfei Yuan University of Edinburgh,Beihang University SICS, Shenzhen Univer ...

  4. 2020 webstorm 最新激活方式 有效期2021年11月 可用

    MIIElT25XE-eyJsaWNlbnNlSWQiOiJPUVQzT0oyNVhFIiwibGljZW5zZWVOYW1lIjoi5rC45LmF5r+A5rS7IGlkZWEubWVkZW1pb ...

  5. 编译 openwrt 及初始配置

    主机为 ubuntu 14 x64 硬件: 优酷土豆宝 cpuMT7620A,内存128M,flash 32M有2个源,用哪个也可以git clone https://github.com/openw ...

  6. 【Oracle】RAC的多实例数据迁移至单机的多实例。

    思路:一般的思路可以通过RMAN进行数据的恢复.由于数据库可以停机,因此,这次试用数据泵(expdp,impdp)进行数据 的导入导出. 1.源数据库导出 通过编写导出shell脚本导出数据,如下: ...

  7. js小数计算引起的精度误差问题

    我记得刚开始学js的时候学到浮点有举例0.1+0.2 它的计算结果是: 0.1+0.20.30000000000000004 很神奇的一个计算,js是弱语言,在精度上没做处理: 我就自己定义了加减乘除 ...

  8. Hadoop集群搭建(六)~安装JDK

    前面集群的准备工作都做完了,本篇记录安装JDK,版本位1.8 1,在opt目录下创建software和module文件夹:software用来放安装包,module为安装目录 2,把JDK和hadoo ...

  9. 2020年启蒙及小学识字练字APP或小程序测评榜

    语文教学改革后,小学识字练字方面显得越来越重要.而市场上大大小小的识字练字应用琳琅满目,不同的定位,不同的核心功能,不同的费用.应该怎么选呢? 本篇将从多个角度对主流识字练字应用进行评测,评估对象为主 ...

  10. 使用numpy和PIL实现图像的手绘效果

    输入 输出 代码如下 图像的手绘效果的实现 from PIL import Image import numpy as np a = np.array(Image.open("index.j ...