#P10835. Sequence with Equal Elements and XOR
Sequence with Equal Elements and XOR
Sequence with Equal Elements and XOR
Given two integers \(n\) and \(m\), determine whether there exists a sequence \(a\) satisfying all the following conditions. The sequence is 1-indexed.
- The length of \(a\) is \(m\), and every element of \(a\) is a positive integer.
- \(a_1 \oplus a_2 \oplus \cdots \oplus a_m = n\), i.e. the XOR of all elements equals \(n\).
- All elements in \(a\) are the same.
Note: If all elements are the same and equal to \(x\), then the XOR operation yields \(x\) when \(m\) is odd and \(0\) when \(m\) is even.
Your task is to output "Yes" if such a sequence exists, otherwise output "No".
inputFormat
The input consists of two integers \(n\) and \(m\) separated by space.
\(n\) and \(m\) satisfy the constraints given in the problem statement.
outputFormat
Output a single line containing either "Yes" if a valid sequence exists or "No" if it does not.
sample
3 1
Yes