A14669 | Reverse
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
You are given two positive integers $x$ and $y$ . You can perform the following operation with $x$ : write it in its binary form without leading zeros, add $0$ or $1$ to the right of it, reverse the binary form and turn it into a decimal number which is assigned as the new value of $x$ .
For example:
- $34$ can be turned into $81$ via one operation: the binary form of $34$ is $100010$ , if you add $1$ , reverse it and remove leading zeros, you will get $1010001$ , which is the binary form of $81$ .
- $34$ can be turned into $17$ via one operation: the binary form of $34$ is $100010$ , if you add $0$ , reverse it and remove leading zeros, you will get $10001$ , which is the binary form of $17$ .
- $81$ can be turned into $69$ via one operation: the binary form of $81$ is $1010001$ , if you add $0$ , reverse it and remove leading zeros, you will get $1000101$ , which is the binary form of $69$ .
- $34$ can be turned into $69$ via two operations: first you turn $34$ into $81$ and then $81$ into $69$ .
Your task is to find out whether $x$ can be turned into $y$ after a certain number of operations (possibly zero).
For example:
- $34$ can be turned into $81$ via one operation: the binary form of $34$ is $100010$ , if you add $1$ , reverse it and remove leading zeros, you will get $1010001$ , which is the binary form of $81$ .
- $34$ can be turned into $17$ via one operation: the binary form of $34$ is $100010$ , if you add $0$ , reverse it and remove leading zeros, you will get $10001$ , which is the binary form of $17$ .
- $81$ can be turned into $69$ via one operation: the binary form of $81$ is $1010001$ , if you add $0$ , reverse it and remove leading zeros, you will get $1000101$ , which is the binary form of $69$ .
- $34$ can be turned into $69$ via two operations: first you turn $34$ into $81$ and then $81$ into $69$ .
Your task is to find out whether $x$ can be turned into $y$ after a certain number of operations (possibly zero).
输入格式
The only line of the input contains two integers $x$ and $y$ ( $1 \le x, y \le 10^{18}$ ).
输出格式
Print YES if you can make $x$ equal to $y$ and NO if you can't.
输入输出样例
输入 #1
3 3
输出 #1
YES
输入 #2
7 4
输出 #2
NO
输入 #3
2 8
输出 #3
NO
输入 #4
34 69
输出 #4
YES
输入 #5
8935891487501725 71487131900013807
输出 #5
YES
In the first example, you don't even need to do anything.
The fourth example is described in the statement.
The fourth example is described in the statement.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted