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”三种中任意一种就输 ...
随机推荐
- 【学习笔记】Golang学习方向整理
前言 作为一个Java开发,给大家说Golang方向,好吓人...溜了溜了... 哦对了,如有不对的地方,还请指出.感谢! 某面试平台golang技能要求简要摘录 掌握 GO 语言,熟悉常用 pack ...
- Flask css 无法实时更新
css代码改完了,但是查看网页源代码css的内容还是很久之前的,根本没有更新 解决方法: 1.浏览器缓存.使用ctrl+F5刷新一下页面 2. 3. from datetime import time ...
- JAVA 16bit CRC_CCITT
JAVA 16bit CRC_CCITT public class CRC_CCITT { static int CRC16_ccitt_table[] = { 0x0000, 0x1189, 0x2 ...
- DIY 作品 及 维修 不定时更新
手机电池DIY充电宝 2块,优质手机电池加一个升压ic ,焊上一个 usb 母头.比买的强多了. 还能调压,最高调到24V 可以带白光焊台. 更换手机 SIM/SD 卡二合一 贴上高温胶带,吹下来. ...
- js实现字符串逆向输出的4种方式
一.第一种方式(利用charAt()这个函数实现) 代码如下: var str="你好世界!!!!"; var str1="";//这里创建一个空字符串用来拼接 ...
- Vue2.0 【第一季】第1节 走进我的Vue2.0
目录 Vue2.0 [第一季]内部指令 第一节 走进我的Vue2.0 Vue2.0 [第一季]内部指令 记录一下我的代码地址:D:/Code/Vue 编辑器:VS code 前置知识: 1.HTML的 ...
- vue基础----自定义组件directive ,bind,update,insert
<div id="app"> <input type="text" v-limit.3="msg" v-focus> ...
- C++基础 学习笔记之一:源代码的格式化
C++基础 学习笔记之一:源代码的格式化 1. 源代码中的标记与空白 C++中的语句是以分号表示语句的结束.在C++中空格和回车以及制表符均为相同作用,即三者通常可以互相替代. 例如可以将一个简单的m ...
- Netty源码分析一<序一Unix网络I/O模型简介>
Unix网络 I/O 模型 我们都知道,为了操作系统的安全性考虑,进程是无法直接操作I/O设备的,其必须通过系统调用请求内核来协助完成I/O动作,而内核会为每个I/O设备维护一个buffer.以下 ...
- Spring Cloud 系列之 Netflix Hystrix 服务监控
Actuator Hystrix 除了可以实现服务容错之外,还提供了近乎实时的监控功能,将服务执行结果和运行指标,请求数量成功数量等等这些状态通过 Actuator 进行收集,然后访问 /actuat ...