309060: CF1618F. Reverse

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Reverse

题意翻译

对于一个二进制数 $x$,每次操作可以在它的末尾加一个 $0$ 或者 $1$,然后将其翻转(自动去除前导 $0$)。 如:$(34)_{10}=(100010)_2$,可以在它的后面加上 $1$ 然后翻转得到 $(1010001)_2=(81)_{10}$。 也可以在它的后面加上 $0$ 翻转得到 $(10001)_2=(17)_{10}$。 $(81)_{10}=(1010001)_2$,可以在它的后面加上 $0$ 翻转得到 $(1000101)_2=(69)_{10}$。 所以可以先将 $34$ 变为 $81$,再将 $81$ 变为 $69$。 现在给定两个正整数 $x$ 和 $y\ (x,y\le 10^{18})$,问能否通过若干次操作后将 $x$ 变成 $y$。输出 YES 或 NO。 翻译贡献者:泷泽三月。

题目描述

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).

输入输出格式

输入格式


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.

Input

题意翻译

对于一个二进制数 $x$,每次操作可以在它的末尾加一个 $0$ 或者 $1$,然后将其翻转(自动去除前导 $0$)。 如:$(34)_{10}=(100010)_2$,可以在它的后面加上 $1$ 然后翻转得到 $(1010001)_2=(81)_{10}$。 也可以在它的后面加上 $0$ 翻转得到 $(10001)_2=(17)_{10}$。 $(81)_{10}=(1010001)_2$,可以在它的后面加上 $0$ 翻转得到 $(1000101)_2=(69)_{10}$。 所以可以先将 $34$ 变为 $81$,再将 $81$ 变为 $69$。 现在给定两个正整数 $x$ 和 $y\ (x,y\le 10^{18})$,问能否通过若干次操作后将 $x$ 变成 $y$。输出 YES 或 NO。 翻译贡献者:泷泽三月。

加入题单

算法标签: