Given N numbers and K, find out if there exists a subset of numbers such that their bitwise xor is K.↵
↵
Input↵
↵
First line contains N and K.↵
The second line contains N space-separated integers A1, A2, ..., AN denoting the N numbers.↵
↵
Output↵
↵
Output "Yes" if such subset exists, "No" otherwise.(without quotes)↵
Constraints↵
↵
1 ≤ N ≤ 200 ↵
↵
↵
1 ≤ K,Ai ≤ 10^9↵
↵
Example↵
↵
Input:↵
4 101↵
↵
↵
1 2 100 1000↵
↵
Output:↵
Yes↵
↵
Explanation↵
↵
Example case 1. We can take xor of 1 and 100 to get 101↵
Note↵
↵
Bitwise xor of a subset A1, A2, .., AN is equal to (..(A1 xor A2) xor A3).. AN).Each bit of bitwise xor of two numbers is calculated separately. The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1. For example, bitwise xor of 1(01) and 3(11) is 2 (10).↵
↵
link for problem:↵
https://www.codechef.com/problems/XORSACK
↵
Input↵
↵
First line contains N and K.↵
The second line contains N space-separated integers A1, A2, ..., AN denoting the N numbers.↵
↵
Output↵
↵
Output "Yes" if such subset exists, "No" otherwise.(without quotes)↵
Constraints↵
↵
1 ≤ N ≤ 200 ↵
↵
↵
1 ≤ K,Ai ≤ 10^9↵
↵
Example↵
↵
Input:↵
4 101↵
↵
↵
1 2 100 1000↵
↵
Output:↵
Yes↵
↵
Explanation↵
↵
Example case 1. We can take xor of 1 and 100 to get 101↵
Note↵
↵
Bitwise xor of a subset A1, A2, .., AN is equal to (..(A1 xor A2) xor A3).. AN).Each bit of bitwise xor of two numbers is calculated separately. The result in each position is 1 if only the first bit is 1 or only the second bit is 1, but will be 0 if both are 0 or both are 1. For example, bitwise xor of 1(01) and 3(11) is 2 (10).↵
↵
link for problem:↵
https://www.codechef.com/problems/XORSACK