QOJ.ac

QOJ

Time Limit: 1.0 s Memory Limit: 2048 MB Total points: 100

#15793. AND and/or OR

Statistics

假设你有一个非负整数 $x$。你可以进行两种类型的操作:

  1. $x := x \text{ AND } 2x$;
  2. $x := x \text{ OR } 2x$;

其中 $\text{AND}$ 和 $\text{OR}$ 分别是按位与和按位或运算。

给定三个整数 $N$、$A$ 和 $B$。如果 $x$ 的初始值为 $N$,是否存在一个操作序列,包含恰好 $A$ 次类型 1 操作和恰好 $B$ 次类型 2 操作,使得最终的 $x$ 值为 $N \cdot 2^k$,其中 $k$ 为某个非负整数?

输入格式

输入包含三个整数 $N$、$A$ 和 $B$ ($1 \le N \le 10^{18}$,$0 \le A, B \le 10^{18}$,$A + B \ge 1$)。

输出格式

如果能够使最终的 $x$ 值等于 $N \cdot 2^k$(其中 $k$ 为非负整数),则输出一行 YES,否则输出 NO

样例

输入 1

14 2 2

输出 1

YES

说明 1

初始时,$x = 14$。你可以进行以下操作序列:

  1. 进行一次类型 1 操作。$x = 14 \text{ AND } 28 = 12$。
  2. 进行一次类型 1 操作。$x = 12 \text{ AND } 24 = 8$。
  3. 进行一次类型 2 操作。$x = 8 \text{ OR } 16 = 24$。
  4. 进行一次类型 2 操作。$x = 24 \text{ OR } 48 = 56$。

最终的 $x$ 值为 $56 = 14 \cdot 2^2$。

输入 2

1 0 9

输出 2

NO

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.