小易有一个长度为N的正整数数列A = {A[1], A[2], A[3]..., A[N]}。
牛博士给小易出了一个难题:
对数列A进行重新排列,使数列A满足所有的A[i] * A[i + 1](1 ≤ i ≤ N - 1)都是4的倍数。
小易现在需要判断一个数列是否可以重排之后满足牛博士的要求。
输入的第一行为数列的个数t(1 ≤ t ≤ 10), 接下来每两行描述一个数列A,第一行为数列长度n(1 ≤ n ≤ 10^5) 第二行为n个正整数A[i](1 ≤ A[i] ≤ 10^9)
对于每个数列输出一行表示是否可以满足牛博士要求,如果可以输出Yes,否则输出No。
2 3 1 10 100 4 1 2 3 4
Yes No
while True: try: t=int(raw_input().strip()) for i in range(t): n=int(raw_input().strip()) a=list(map(int,raw_input().strip().split())) count4,count2,countodd=0,0,0 for j in a: if j%4==0: count4+=1 else: if j%4==2: count2+=1 else: countodd+=1 if count2==0: if count4>=countodd-1: print('Yes') else: print('No') else: if count4>=countodd: print('Yes') else: print('No') except: break