A12632 | Remainder
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
You are given a huge decimal number consisting of $n$ 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 \le y < x < n$ . Your task is to calculate the minimum number of operations you should perform to obtain the number that has remainder $10^y$ modulo $10^x$ . In other words, the obtained number should have remainder $10^y$ when divided by $10^x$ .
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 \le y < x < n$ . Your task is to calculate the minimum number of operations you should perform to obtain the number that has remainder $10^y$ modulo $10^x$ . In other words, the obtained number should have remainder $10^y$ when divided by $10^x$ .
输入格式
The first line of the input contains three integers $n, x, y$ ( $0 \le y < x < n \le 2 \cdot 10^5$ ) — 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.
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.
输出格式
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$ .
输入输出样例
输入 #1
11 5 2 11010100101
输出 #1
1
输入 #2
11 5 1 11010100101
输出 #2
3
In the first example the number will be $11010100100$ after performing one operation. It has remainder $100$ modulo $100000$ .
In the second example the number will be $11010100010$ after performing three operations. It has remainder $10$ modulo $100000$ .
In the second example the number will be $11010100010$ after performing three operations. It has remainder $10$ modulo $100000$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted