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”三种中任意一种就输 ...
随机推荐
- IIS6.0文件解析漏洞和短文件名漏洞复现
一.IIS6.0文件解析漏洞 1.ASP一句话木马的准备 新建木马文件“muma.txt”,将“我asp是一句话木马:<%eval request("asp")%>”写 ...
- 盘点Linux运维常用工具(一)-web篇之httpd
#前言:想把自己学的各种服务进行分类归档起来,于是就写了盘点Linux运维常用工具,Linux方面使用到的web应用服务有httpd(apache).nginx.tomcat.lighttpd,先了解 ...
- VOIP RTP RTSP 实现 Baresip 源码分析
RTP 使用 udp 进行数据传输,udp 是不能保证,数据包一定可以到达的,也不提供时序.同时还有 MTU 限制. RTCP 用来配合 RTP 提供,传输报告,会话建立和退出. 一大批参考规范 * ...
- ubuntu 安装flask+nginx+gunicorn 待定
第一步 先检查服务器环境 pip python3 mysql redis 能下就下,该升级就升级 第二步 如果你的flask程序在github上 请使用git clone 地址 下载下来(如果是私 ...
- mac笔记本编译go-ethereum报错CoreServices/CoreServices.h' file not found
查看xcode是否安装: $ xcode-select --install xcode-select: error: command line tools are already installed, ...
- ajax 瀑布流 demo
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 再说scss
1. CSS预处理器 定义了一种新的专门的编程语言,编译后成正常的CSS文件.为CSS增加一些编程的特性,无需考虑浏览器的兼容问题,让CSS更加简洁,适应性更强,可读性更佳,更易于代码的维护等诸多好处 ...
- 代码备份 | 博客侧边栏公告(支持HTML代码)(支持JS代码)
博客侧边栏公告(支持HTML代码)(支持JS代码) <div id='btnList'> <a class="ivu-btn ivu-btn-primary" h ...
- 【分布式锁】03-使用Redisson实现RedLock原理
前言 前面已经学习了Redission可重入锁以及公平锁的原理,接着看看Redission是如何来实现RedLock的. RedLock原理 RedLock是基于redis实现的分布式锁,它能够保证以 ...
- 「每天五分钟,玩转 JVM」:对象访问定位
前言 在「对象内存布局」一节中,我们了解到对象头中包含了一个叫做类型指针的东西,即对象指向它的类元数据的指针,虚拟机通过这个指针来确定这个对象是哪个类的实例.但是,并不是所有的虚拟机都是这么去做的.不 ...