A14098 | Enormous XOR
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
You are given two integers $l$ and $r$ in binary representation. Let $g(x, y)$ be equal to the [bitwise XOR](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) of all integers from $x$ to $y$ inclusive (that is $x \oplus (x+1) \oplus \dots \oplus (y-1) \oplus y$ ). Let's define $f(l, r)$ as the maximum of all values of $g(x, y)$ satisfying $l \le x \le y \le r$ .
Output $f(l, r)$ .
Output $f(l, r)$ .
输入格式
The first line contains a single integer $n$ ( $1 \le n \le 10^6$ ) — the length of the binary representation of $r$ .
The second line contains the binary representation of $l$ — a string of length $n$ consisting of digits $0$ and $1$ ( $0 \le l < 2^n$ ).
The third line contains the binary representation of $r$ — a string of length $n$ consisting of digits $0$ and $1$ ( $0 \le r < 2^n$ ).
It is guaranteed that $l \le r$ . The binary representation of $r$ does not contain any extra leading zeros (if $r=0$ , the binary representation of it consists of a single zero). The binary representation of $l$ is preceded with leading zeros so that its length is equal to $n$ .
The second line contains the binary representation of $l$ — a string of length $n$ consisting of digits $0$ and $1$ ( $0 \le l < 2^n$ ).
The third line contains the binary representation of $r$ — a string of length $n$ consisting of digits $0$ and $1$ ( $0 \le r < 2^n$ ).
It is guaranteed that $l \le r$ . The binary representation of $r$ does not contain any extra leading zeros (if $r=0$ , the binary representation of it consists of a single zero). The binary representation of $l$ is preceded with leading zeros so that its length is equal to $n$ .
输出格式
In a single line output the value of $f(l, r)$ for the given pair of $l$ and $r$ in binary representation without extra leading zeros.
输入输出样例
输入 #1
7 0010011 1111010
输出 #1
1111111
输入 #2
4 1010 1101
输出 #2
1101
In sample test case $l=19$ , $r=122$ . $f(x,y)$ is maximal and is equal to $127$ , with $x=27$ , $y=100$ , for example.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted