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;
}

最新文章

  1. Mina、Netty、Twisted一起学(十):线程模型
  2. Erlang 进程被抢占的条件——一个进程长时霸占调度器的极端示例
  3. Yii2 初体验
  4. innobackupex err2
  5. Winform自定义分页控件的实现
  6. 教你怎样在ppt2010抠图的小技巧|用ppt2010抠图的方法
  7. .Net 4.X 提前用上 .Net Core 的配置模式以及热重载配置
  8. php 将一个或多个二维数组组合成一个二维数组并根据某个字段排序排序
  9. Linux上修改主机名
  10. @Scope用法
  11. Python3学习笔记19-继承和多态
  12. js的闭包的一个示例说明
  13. 关于ie7下display:inline-block;不支持的解决方案。
  14. Recover database using backup controlfile until cancel
  15. 给Ubuntu添加清华的软件源
  16. 第二届CCF软件能力认证
  17. Ubuntu菜鸟入门(十)—— Flash控件安装
  18. Java学习之路(六):集合
  19. java的map取值
  20. json剥离

热门文章

  1. 从0开始搭建kafka客户端
  2. 报错: raise ImproperlyConfigured(&#39;mysqlclient 1.3.13 or newer is required; you have %s.&#39; % Database.__version__)
  3. 基于JWT实现token验证
  4. python社区要放弃了pip?版本信息里带警告很不寻常哦
  5. C#如何实现大小写转换
  6. 【Win10】我们无法更新系统保留的分区
  7. js获得用户网络状况API
  8. node 微信授权 获取openid
  9. go源码分析(五) 获取函数名和调用者的函数名
  10. iview Checkbox 多选框 v-model 赋值方法 this.innerValueArr = [this.previousValue]