Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <algorithm>
- #include <vector>
- #include <cstring>
- #include <deque>
- #include <time.h>
- #include <stack>
- #include <stdio.h>
- #include <map>
- #include <set>
- #include <string>
- #include <fstream>
- #include <queue>
- #define mp make_pair
- #define pb push_back
- #define PI 3.14159265358979323846
- #define MOD 1000000007
- #define INF ((ll)1e+15)
- #define x1 fldgjdflgjhrthrl
- #define x2 fldgjdflgrtyrtyjl
- #define y1 fldggfhfghjdflgjl
- #define y2 ffgfldgjdflgjl
- typedef long long ll;
- using namespace std;
- ll b[200500],i,j,n,k,k1,k2,m,x,y;
- ll a[205000];
- map <ll,ll> f[35],g;
- ll Abs(ll x)
- {
- if (x < 0)
- return -x;
- return x;
- }
- int main()
- {
- //cout << ((-1) xor 1) << endl;
- ll ans = 0;
- cin >> n;
- k1 = 1;
- for (i = 0; i < n; i++)
- {
- cin >> a[i];
- g[a[i]]++;
- ans ^= a[i];
- for (j = 1; j < 32; j++)
- {
- x = a[i]%(1LL<<j);
- if (x < 0)
- x += (1LL<<j);
- f[j][x]++;
- }
- }
- for (i = 0; i < n-1; i++)
- {
- //cout << ans << endl;
- k = 1;
- g[a[i]]--;
- if ((g[a[i]]&1)==k)
- {
- ans ^= -1;
- k ^= 1;
- }
- for (j = 31; j >= 1; j--)
- {
- x = a[i]%(1LL<<j);
- if (x < 0)
- x += (1LL<<j);
- f[j][x]--;
- if ((f[j][x]&1) == k)
- {
- ans ^= j;
- k ^= 1;
- //cout << ans << endl;
- }
- }
- }
- cout << ans << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement