#P15664. [ICPC 2025 Jakarta R] AND and/or OR

[ICPC 2025 Jakarta R] AND and/or OR

题目描述

Suppose you have a non-negative integer xx. You can do two types of operations:

  • x:=x AND 2xx := x \textrm{ AND } 2x;
  • x:=x OR 2xx := x \textrm{ OR } 2x;

where AND\textrm{AND} and OR\textrm{OR} are the bitwise AND and bitwise OR operations, respectively.

You are given three integers NN, AA, and BB.

If the value of xx is initially NN, is there any sequence of operations that consists of exactly\textbf{exactly} AA operations of type 1 and exactly\textbf{exactly} BB operations of type 2, such that the final value of xx is N2kN \cdot 2^k for some non-negative integer kk?

输入格式

Input consists of three integers NN, AA, and BB (1N10181 \leq N \leq 10^{18}, 0A,B10180 \leq A, B \leq 10^{18}, A+B1A + B \geq 1).

输出格式

Output a single line containing YES\texttt{YES} if it is possible to make the final value of xx equal to N2kN \cdot 2^k where kk is a non-negative integer, or NO\texttt{NO} otherwise.

14 2 2
YES
1 0 9
NO

提示

Explanation of Sample 1:\textit{Explanation of Sample 1:} Initially, x=14x = 14. You can do the following sequence of operations:

  • Do a type 1 operation. x=14 AND 28=12x = 14 \textrm{ AND } 28 = 12.
  • Do a type 1 operation. x=12 AND 24=8x = 12 \textrm{ AND } 24 = 8.
  • Do a type 2 operation. x=8 OR 16=24x = 8 \textrm{ OR } 16 = 24.
  • Do a type 2 operation. x=24 OR 48=56x = 24 \textrm{ OR } 48 = 56.

The final value of xx is 56=142256 = 14 \cdot 2^2.