F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Hakase and Nano

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3196    Accepted Submission(s): 1195


Problem Description
Hakase and Nano are playing an ancient pebble game (pebble is a kind of rock). There are n packs of pebbles, and the i-th pack contains ai pebbles. They take turns to pick up pebbles. In each turn, they can choose a pack arbitrarily and pick up at least one pebble in this pack. The person who takes the last pebble wins.

This time, Hakase cheats. In each turn, she must pick pebbles following the rules twice continuously. Suppose both players play optimally, can you tell whether Hakase will win?
 

Input
The first line contains an integer $ T \left(1 \leq T \leq 20 \right) $ representing the number of test cases.

For each test case, the first line of description contains two integers $ n \left(1 \leq n \leq 10^6 \right) $ and d ( d = 1 or d = 2 ) . If $ d = 1 $, Hakase takes first and if $ d = 2 $, Nano takes first. n represents the number of pebble packs.

The second line contains n integers, the i-th integer $ a_{i} \left( 1 \leq a_{i} \leq 10^{9} \right) $ represents the number of pebbles in the i-th pebble pack.
 

Output
For each test case, print “Yes” or “No” in one line. If Hakase can win, print “Yes”, otherwise, print “No”.
 

Sample Input
2 3 1 1 1 2 3 2 1 1 2
 

Sample Output
Yes No
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2025 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2025-04-01 08:28:37, Gzip enabled