## Yet Another Contest 8 P2 - No More Modern Art

View as PDF

Points: 7 (partial)
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

Josh has a wall of colour . However, last night, people graffitied the entire wall! Josh now needs to obtain a large amount of paint of colour so that he can repaint the wall, covering up the modern art.

In his storeroom, Josh finds buckets of paint. The -th bucket has paint of colour . Josh can repeatedly perform the following operation:

• First, select one bucket of paint.
• Then, evenly divide the paint in this bucket amongst the remaining buckets. The chosen bucket is then discarded.
• If paint of colour was poured into a bucket of paint of colour , then the bucket will now contain paint of colour , due to the mysterious chemical properties of the paint.

Here, denotes the bitwise XOR operator.

Can you help Josh determine whether he can end up with exactly one bucket, with this bucket containing paint of colour ?

#### Input Specification

The first line contains two space-separated integers, and .

The second line contains space-separated integers, .

#### Output Specification

On a single line, output YES if Josh can end up with a single bucket containing paint of colour , and NO otherwise.

#### Sample Input 1

3 1
1 2 3

#### Sample Output 1

YES

#### Explanation for Sample Output 1

Initially, there are three buckets, containing paint of colours , and respectively. Even though Josh already has paint of colour , he wants a single bucket of colour , with no other buckets.

First, Josh can pour the paint in bucket into the other two buckets. The bucket which initially contained paint of colour now contains paint of colour . The bucket which initially contained paint of colour now contains paint of colour .

At this point, Josh has two buckets, containing paint of colours and respectively. If he pours the paint in the first bucket into the second bucket, he will end up with a single bucket containing paint of colour .

#### Sample Input 2

3 4
1 2 3

#### Sample Output 2

NO