CF1618F.Reverse

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given two positive integers xx and yy. You can perform the following operation with xx: write it in its binary form without leading zeros, add 00 or 11 to the right of it, reverse the binary form and turn it into a decimal number which is assigned as the new value of xx.

For example:

  • 3434 can be turned into 8181 via one operation: the binary form of 3434 is 100010100010, if you add 11, reverse it and remove leading zeros, you will get 10100011010001, which is the binary form of 8181.
  • 3434 can be turned into 1717 via one operation: the binary form of 3434 is 100010100010, if you add 00, reverse it and remove leading zeros, you will get 1000110001, which is the binary form of 1717.
  • 8181 can be turned into 6969 via one operation: the binary form of 8181 is 10100011010001, if you add 00, reverse it and remove leading zeros, you will get 10001011000101, which is the binary form of 6969.
  • 3434 can be turned into 6969 via two operations: first you turn 3434 into 8181 and then 8181 into 6969.

Your task is to find out whether xx can be turned into yy after a certain number of operations (possibly zero).

给你两个正整数 xx 和 yy。你可以对 xx 执行如下操作:将其写成不含前导零的二进制形式,然后在该二进制串右侧添加一个 00 或 11,接着将整个二进制串反转,并去掉前导零,最后将所得二进制数转为十进制数,作为新的 xx 值。

例如:

  • 3434 可通过一次操作变为 8181:3434 的二进制形式为 100010100010;若在其右侧添加 11,得到 10001011000101,反转后为 10100011010001(去掉前导零后仍为 10100011010001),其对应的十进制数为 8181。
  • 3434 可通过一次操作变为 1717:3434 的二进制形式为 100010100010;若在其右侧添加 00,得到 10001001000100,反转后为 00100010010001,去掉前导零后为 1000110001,其对应的十进制数为 1717。
  • 8181 可通过一次操作变为 6969:8181 的二进制形式为 10100011010001;若在其右侧添加 00,得到 1010001010100010,反转后为 0100010101000101,去掉前导零后为 10001011000101,其对应的十进制数为 6969。
  • 3434 可通过两次操作变为 6969:先将 3434 变为 8181,再将 8181 变为 6969。

你的任务是判断:经过若干次(可能为零次)上述操作后,xx 是否能变为 yy。

输入格式

The only line of the input contains two integers xx and yy (1≤x,y≤10181 \le x, y \le 10^{18}).

输入仅包含一行,其中有两个整数 xx 和 yy(1≤x,y≤10181 \le x, y \le 10^{18})。

输出格式

Print YES if you can make xx equal to yy and NO if you can't.

如果可以使 xx 等于 yy,则输出 YES;否则输出 NO。

输入输出样例

  • 输入#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.

在第一个例子中,你甚至无需进行任何操作。

第四个例子在题目描述中已给出。

输入解题思路,AI测评打分。不知道怎么写?

首页