当前位置:   article > 正文

Array with Odd Sum(CF-1296A)_j - array with odd sum

j - array with odd sum

Problem Description

You are given an array a consisting of n integers.

In one move, you can choose two indices 1≤i,j≤n such that i≠j and set ai:=aj. You can perform such moves any number of times (possibly, zero). You can choose different indices in different operations. The operation := is the operation of assignment (i.e. you choose i and j and replace ai with aj).

Your task is to say if it is possible to obtain an array with an odd (not divisible by 2) sum of elements.

You have to answer t independent test cases.

Input

The first line of the input contains one integer t (1≤t≤2000) — the number of test cases.

The next 2t lines describe test cases. The first line of the test case contains one integer n (1≤n≤2000) — the number of elements in a. The second line of the test case contains n integers a1,a2,…,an (1≤ai≤2000), where ai is the i-th element of a.

It is guaranteed that the sum of n over all test cases does not exceed 2000 (∑n≤2000).

Output

For each test case, print the answer on it — "YES" (without quotes) if it is possible to obtain the array with an odd sum of elements, and "NO" otherwise.

Examples

Input

5
2
2 3
4
2 2 8 8
3
3 3 3
4
5 5 5 5
4
1 1 1 1

Output

YES
NO
YES
NO
NO

题意:t 组数据,每组给出 n 个数,对于任意两个数 a[i]、a[j],可以令 a[i]=a[j],问在有限次操作的情况下,这 n 个数的和是否能变成一个奇数

思路:简单的思维题,首先,如果这 n 个数全是偶数,那么一定不可能,然后,如果这 n 个数都是奇数,且 n 是一个偶数,那么无论怎么变,偶数个奇数相加一定是偶数,也不可能,排除上述两种情况外,其他情况全都可能

Source Program

  1. #include<iostream>
  2. #include<cstdio>
  3. #include<cstdlib>
  4. #include<string>
  5. #include<cstring>
  6. #include<cmath>
  7. #include<ctime>
  8. #include<algorithm>
  9. #include<utility>
  10. #include<stack>
  11. #include<queue>
  12. #include<vector>
  13. #include<set>
  14. #include<map>
  15. #include<bitset>
  16. #define PI acos(-1.0)
  17. #define INF 0x3f3f3f3f
  18. #define LL long long
  19. #define Pair pair<int,int>
  20. LL quickPow(LL a,LL b){ LL res=1; while(b){if(b&1)res*=a; a*=a; b>>=1;} return res; }
  21. LL multMod(LL a,LL b,LL mod){ a%=mod; b%=mod; LL res=0; while(b){if(b&1)res=(res+a)%mod; a=(a<<=1)%mod; b>>=1; } return res%mod;}
  22. LL quickMultPowMod(LL a, LL b,LL mod){ LL res=1,k=a; while(b){if((b&1))res=multMod(res,k,mod)%mod; k=multMod(k,k,mod)%mod; b>>=1;} return res%mod;}
  23. LL quickPowMod(LL a,LL b,LL mod){ LL res=1; while(b){if(b&1)res=(a*res)%mod; a=(a*a)%mod; b>>=1; } return res; }
  24. LL getInv(LL a,LL mod){ return quickPowMod(a,mod-2,mod); }
  25. LL GCD(LL x,LL y){ return !y?x:GCD(y,x%y); }
  26. LL LCM(LL x,LL y){ return x/GCD(x,y)*y; }
  27. const double EPS = 1E-15;
  28. const int MOD = 1000000000+7;
  29. const int N = 2000+5;
  30. const int dx[] = {0,0,1,-1,1,1,-1,-1};
  31. const int dy[] = {1,-1,0,0,1,-1,1,-1};
  32. using namespace std;
  33. int a[N];
  34. int main() {
  35. int t;
  36. scanf("%d", &t);
  37. while (t--) {
  38. int n;
  39. scanf("%d", &n);
  40. int odd = 0, even = 0;
  41. for (int i = 1; i <= n; i++) {
  42. scanf("%d", &a[i]);
  43. if (a[i] % 2)
  44. odd++;
  45. else
  46. even++;
  47. }
  48. if (even == n)
  49. printf("NO\n");
  50. else {
  51. if (n % 2 == 0 && odd == n)
  52. printf("NO\n");
  53. else
  54. printf("YES\n");
  55. }
  56. }
  57. return 0;
  58. }

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/神奇cpp/article/detail/745340
推荐阅读
相关标签
  

闽ICP备14008679号