fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n; cin >> n;
  6. vector<int> arr(n);
  7. long long ans = 0, x;
  8.  
  9. for(int i=0;i<n;i++) cin >> arr[i];
  10.  
  11. if (n % 2 == 0) {
  12. cout << 0;
  13. return 0;
  14. }
  15.  
  16. for(int i=0;i<n;i+=2){
  17. ans ^= arr[i];
  18. }
  19. cout << ans % 1000000007;
  20. }
Success #stdin #stdout 0.01s 5284KB
stdin
3
1 2 4
stdout
5