Poisonous gas
Practice
3.8 (26 votes)
Basic programming
Bit manipulation
Bit manipulation
Easy
Problem
78% Success 11812 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

You are in a battle field and your enemy has an army of N soldiers. Each soldier has a strength denoted by an array A. Your enemy will select some soldiers such that total strength of selected soldiers is maximum. You have a poisonous gas and you can use it on the selected soldiers as many times as you want. If the total strength is even, the poisonous gas will decrease the total strength of the selected soldiers to half of the total strength, otherwise it will not affect them. Your task is to tell if its possible to reduce the total strength to 1 or not.

 

Input Format:

First line contains an integer T, denoting the number of test cases.

First line of each test case contains an integer N, denoting the number of soldiers.

Second line of each test case contains N space-separated integers, denoting the strength of the soldiers.

 

Output Format:

For each test case, print Yes if its possible to reduce the total strength to 1, otherwise print No.

 

Constraints:

\(1 \le T \le 10\)

\(1 \le N \le 10^5\)

\(-10^9 \le A[i] \le 10^9\)

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
23 votes
Tags:
Basic ProgrammingBit ManipulationBit manipulationEasyPrefix sumPrefix-Sum
Points:20
29 votes
Tags:
BitmaskBasic ProgrammingBit ManipulationBasics of Bit ManipulationGreedy AlgorithmsBit manipulation
Points:20
14 votes
Tags:
Bit manipulationBit ManipulationBasics of Bit ManipulationBasic Programming