fork download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. const long long MaxN = 1e6 + 5;
  4. long long n,a[MaxN];
  5. void input()
  6. {
  7. cin >> n;
  8. for (long long i=1; i<=n; i++)
  9. {
  10. cin >> a[i];
  11. }
  12. }
  13. void solve()
  14. {
  15. long long cnt0=1, cnt1=0, ans=0, sum=0;
  16. for (long long i=1;i<=n; i++)
  17. {
  18. sum^=a[i];
  19. if(__builtin_popcountll(sum)&1)
  20. {
  21. ans+=cnt0;
  22. cnt1++;
  23. }
  24. else
  25. {
  26. ans+=cnt1;
  27. cnt0++;
  28. }
  29. }
  30. cout << ans;
  31.  
  32. }
  33. int main()
  34. {
  35. ios_base::sync_with_stdio(0);
  36. cin.tie(0);
  37. input();
  38. solve();
  39. }
  40.  
  41.  
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
Standard output is empty