fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define int long long
  5.  
  6. const int N = 1e6 + 5;
  7. int n , sum;
  8. int a[N];
  9. int cnt[3];
  10.  
  11. main()
  12. {
  13. ios::sync_with_stdio(0);
  14. cin.tie(0);
  15. cin >> n;
  16. for(int i = 1 ; i <= n ; i++)
  17. {
  18. cin >> a[i];
  19. sum += a[i];
  20. if(a[i] % 2 == 0)
  21. cnt[0]++;
  22. else
  23. cnt[1]++;
  24. }
  25. if(sum % 2 == 0)
  26. cout << cnt[0] * (cnt[0] - 1) / 2
  27. + cnt[1] * (cnt[1] - 1) / 2 << "\n";
  28. else
  29. cout << cnt[0] * cnt[1] << "\n";
  30.  
  31.  
  32.  
  33. }
Success #stdin #stdout 0.01s 5288KB
stdin
Standard input is empty
stdout
0