No.683 Two Operations No.3
Problem Statement
You are given non-negative integers $A,B$ and have $2$ integers $X=0,Y=0$. You may perform the following $2$ operations any number of times in any order. Determine whether it is possible to make $X=A,Y=B$.
Let $X',Y'$ denote the values of $X,Y$ after an operation, respectively.
Operation 1: $X'=X\times 2$ $,$ $Y'=Y+1$
Operation 2: $X'=X+1$ $,$ $Y'=Y\times 2$
Input
$A$ $B$
$0\le A,B\le 10^{18}$
Output
Print "Yes" if it is possible to make $X=A,Y=B$, and "No" otherwise. Print a newline at the end.
Sample
Sample 1
Input
4 5
Output
Yes
You can make $X=4,Y=5$ by performing the operations in the order Operation 1 $\rightarrow$ Operation 2 $\rightarrow$ Operation 2 $\rightarrow$ Operation 1. In this case, the value of $(X,Y)$ changes as follows.
$(0,0)\rightarrow (0,1)\rightarrow (1,2)\rightarrow (2,4)\rightarrow (4,5)$
Sample 2
Input
1 1
Output
No
Sample 3
Input
0 0
Output
Yes
There are cases where no operation is needed.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
Pulmn
WA_TLE