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”三种中任意一种就输 ...
随机推荐
- PAT-字符串处理-B1006 换个格式输出整数 (15分)
题目描述: 让我们用字母 B 来表示“百”.字母 S 表示“十”,用 12...n 来表示不为零的个位数字 n(<10),换个格式来输出任一个不超过 3 位的正整数.例如 234 应该被输出为 ...
- sf-git机制
为什么要专门写一篇关于sf科技公司的GIT管理机制呢?因为本周经历了两天的学习和考试,刚开始没在意,因为之前公司也用的GIT,所以没怎么看视频,就看了文档,练习考试时候才发现并非以前的那种git流程, ...
- LinkedHashMap源码解读
1. 前言 还是从面试中来,到面试中去.面试官在面试 Redis 的时候经常会问到,Redis 的 LRU 是如何实现的?如果让你实现 LRU 算法,你会怎么实现呢?除了用现有的结构 LinkedHa ...
- wentiqingdan
1. Python不用在行尾加分号,也不要用分号将两条命令放在同一行,但加上分号也能执行,不像C/C++分号是必须加的,缺了就会出错. 2. C属于编译型语言,Python属解型语言 编译型的优点是& ...
- Lucene查询语法汇总
目录 一.单词查询 二.通配符查询 三.模糊查询 四.近似查询 五.范围查询 六.优先级查询 七.逻辑操作 八.括号分组 九.转义特殊字符 Lucene是目前最为流行的开源全文搜索引擎工具包,提供了完 ...
- require.context('.', true, /\.router\.js/) webpack 编译的时候读取目录文件
const routerList = [] function importAll (r) { r.keys().map(value => { r(value).default.map(item ...
- vue cli3 的 eslint 修改为4个空格
只需要修改如下两个文件
- DOM-XSS攻击原理与防御
XSS的中文名称叫跨站脚本,是WEB漏洞中比较常见的一种,特点就是可以将恶意HTML/JavaScript代码注入到受害用户浏览的网页上,从而达到劫持用户会话的目的.XSS根据恶意脚本的传递方式可以分 ...
- Android 登陆功能的实现(访问WebServices 解析返回的JSON结果)
1. WebServices返回的JSON结果 { , "Result": [{ ", ", ", " }] } 2.访问WEB服务代码 i ...
- input标签的accept属性、JQuery绑定keyDown事件
一. input标签的accept属性 当我们上传文件或者注册上传头像时,我们可以一般都是使用: <input type="file" id="my_file&qu ...