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. Windows环境下docker的安装与配置

    Docker是一种容器技术,可以在操作系统中隔离出若干个独立的程序运行环境,这些环境既可以共享宿主机的资源,另一方面他们之间相互独立,互不影响,也不会对宿主机的环境产生影响.与虚拟化技术不同的是,Do ...

  2. AB实验的高端玩法系列4- 实验渗透低?用户未被触达?CACE/LATE

    CACE全称Compiler Average Casual Effect或者Local Average Treatment Effect.在观测数据中的应用需要和Instrument Variable ...

  3. 仿IntelliJ Darcula的Swing主题FlatLaf使用方法

    最近Sandeepin想写个基于Java Swing的RSS阅读器练练手,不过Swing默认主题太丑了,切成系统原生的主题也不是非常好看,正好感觉开发时用的IDEA主题很不错,不管是Light还是Da ...

  4. python如何用format进行进制转换与如何删除进制前缀

    10进行十进制,十六进制,八进制,二进制的转换:(#:保留进制前缀)对于带着进制前缀的,如"0x"“0o”“0b”,可以直接在后面加上’x’‘o’'b’进行删除:其他的一些小技巧: ...

  5. 附014.Kubernetes Prometheus+Grafana+EFK+Kibana+Glusterfs整合性方案

    一 glusterfs存储集群部署 注意:以下为简略步骤,详情参考<附009.Kubernetes永久存储之GlusterFS独立部署>. 1.1 架构示意 略 1.2 相关规划 主机 I ...

  6. 在Windows中像Linux里一样使用CMake和make

    1. 安装GCC环境 1.1 安装MinGW(Minimalist GNU for Windows) 首先下载MinGW,并安装.安装完成之后运行MinGW Installer.界面如下.勾选自己需要 ...

  7. 03-Vue数据请求

    1. vue-resource vue-resource jsonp请求 <body> <div id="app"> <!-- v-model 监听表 ...

  8. C++:利用全局钩子实现键盘锁

    在家看网课,记笔记不方便.于是就想弄个键盘锁,方便学习(在寝室也好把外接键盘放上去打游戏). 其实这东西挺简单的,就三行代码. HHOOK hk; LRESULT CALLBACK kbproc(in ...

  9. Python文本文件读写操作时的字符编码问题

    说明:文本文件的字符编码问题只存在t模式中,如:open('a.txt', mode='rt') 编码(encode): 我们输入的任何字符想要以文件(如.txt)的形式保存在计算机的硬盘上, 必须先 ...

  10. 从发布订阅模式入手读懂Node.js的EventEmitter源码

    前面一篇文章setTimeout和setImmediate到底谁先执行,本文让你彻底理解Event Loop详细讲解了浏览器和Node.js的异步API及其底层原理Event Loop.本文会讲一下不 ...