A. Remainder Codeforces Round #560 (Div. 3)
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)的更多相关文章
- Codeforces Round #560 (Div. 3) Microtransactions
Codeforces Round #560 (Div. 3) F2. Microtransactions (hard version) 题意: 现在有一个人他每天早上获得1块钱,现在有\(n\)种商品 ...
- Codeforces Round #560 Div. 3
题目链接:戳我 于是...风浔凌弱菜又去写了一场div.3 总的来说,真的是比较简单.......就是.......不开long long见祖宗 贴上题解-- A 给定一个数,为01串,每次可以翻转一 ...
- Codeforces Round #560 (Div. 3)A-E
A. Remainder output standard output You are given a huge decimal number consisting of nn digits. It ...
- Codeforces Round #277 (Div. 2) 题解
Codeforces Round #277 (Div. 2) A. Calculating Function time limit per test 1 second memory limit per ...
- Codeforces Round #422 (Div. 2)
Codeforces Round #422 (Div. 2) Table of Contents Codeforces Round #422 (Div. 2)Problem A. I'm bored ...
- Codeforces Round #272 (Div. 2) 题解
Codeforces Round #272 (Div. 2) A. Dreamoon and Stairs time limit per test 1 second memory limit per ...
- 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 ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...
随机推荐
- linux 安装 memcached
1.Linux系统安装memcached,首先要先安装libevent库. yum install libevent libevent-deve 2.安装memcached yum install - ...
- 无损卡尔曼滤波UKF(3)-预测-生成Sigma点
无损卡尔曼滤波UKF(3)-预测-生成Sigma点 1 选择创建Sigma点 A 根据 已知上一个时间戳迭代出来的 后验状态 x_{k|k} 和后验协方差矩阵 P_{k|k} 他们代表当前状态的分布. ...
- 分享一个快速审查js操作Dom的css
第一步 打开开发者工具第二步 打开 Sources 面板第三步 执行用户操作让对象可见(例如鼠标悬停)第四步 在元素可见的时候按下 F8(与“暂停脚本执行”按钮相同)第五步 点击开发者工具左上角的“选 ...
- 移动webApp必备技能一、WebApp 里Meta标签大全,webappmeta标签大全
1.先说说mate标签里的viewport: viewport即可视区域,对于桌面浏览器而言,viewport指的就是除去所有工具栏.状态栏.滚动条等等之后用于看网页的区域.对于传统WEB页面来说,9 ...
- Java反射之成员方法的反射
上一篇介绍了Java反射之成员变量的反射,这次介绍成员方法的反射. [一]Method类 Method类中封装了所有java方法的属性,包括该方法是否私有,该方法的修饰符,返回值,参数,抛的错误等等. ...
- 一个交互式可视化Python库——Bokeh
本篇为<Python数据可视化实战>第十篇文章,我们一起学习一个交互式可视化Python库--Bokeh. Bokeh基础 Bokeh是一个专门针对Web浏览器的呈现功能的交互式可视化Py ...
- 简说Python之Jupyter Notebook
目录 简说Python之Jupyter Notebook 1.Jupyter Notebook 系统环境:Ubuntu 18.04.1 LTS Python使用的是虚拟环境:virutalenv Py ...
- 【vue生命周期】- 详解
这篇文章通俗易懂,写的不错,本文转载至:https://www.cnblogs.com/happ0/p/8075562.html 详解Vue Lifecycle 先来看看vue官网对vue生命周期的介 ...
- 深入理解Java内存模型(摘)
--摘自 周志明<深入理解Java虚拟机> 转自 https://www.jianshu.com/p/15106e9c4bf3 深入理解Java内存模型(摘) java内存模型(Java ...
- JDK中线程池参详细解析
在jdk中为我们提供了三种创建线程池的方式,但是在阿里的编码规范里面都是明确禁止使用这三种api去创建线程池,推荐我们去自定义线程池.为什么? 要回答为什么,我们需要明白创建线程池时,各参数的作用: ...