fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. int T,n,S,dem;
  5. int a[1001];
  6. int s[1001];
  7. int main() {
  8. ios_base::sync_with_stdio(false);
  9. cin.tie(NULL);
  10. cin >> T;
  11. while(T--)
  12. {
  13. cin >> n;
  14. for(int i = 1; i <= n; i++) cin >> a[i];
  15. s[1] = a[1];
  16. for(int i = 2; i <= n; i++) s[i] = s[i-1] + a[i];
  17. for(int i = 1; i <= n; i++)
  18. {
  19. for(int j = i; j <= n; j++)
  20. {
  21. S = s[j] - s[i-1];
  22. if(S%2 == 0) dem++;
  23. }
  24. }
  25. cout << dem << endl;
  26. dem = 0;
  27. }
  28. return 0;
  29. }
Success #stdin #stdout 0s 5268KB
stdin
1
6
1 2 2 3 4 1
stdout
9