Advertisement
Guest User

Untitled

a guest
Jul 6th, 2015
381
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <algorithm>
  4. #include <vector>
  5. #include <cstring>
  6. #include <deque>
  7. #include <time.h>
  8. #include <stack>
  9. #include <stdio.h>
  10. #include <map>
  11. #include <set>
  12. #include <string>
  13. #include <fstream>
  14. #include <queue>
  15. #define mp make_pair
  16. #define pb push_back
  17. #define PI 3.14159265358979323846
  18. #define MOD 1000000007
  19. #define INF ((ll)1e+15)
  20. #define x1 fldgjdflgjhrthrl
  21. #define x2 fldgjdflgrtyrtyjl
  22. #define y1 fldggfhfghjdflgjl
  23. #define y2 ffgfldgjdflgjl
  24. typedef long long ll;
  25. using namespace std;
  26. ll b[200500],i,j,n,k,k1,k2,m,x,y;
  27. ll a[205000];
  28. map <ll,ll> f[35],g;
  29. ll Abs(ll x)
  30. {
  31. if (x < 0)
  32. return -x;
  33. return x;
  34. }
  35. int main()
  36. {
  37. //cout << ((-1) xor 1) << endl;
  38. ll ans = 0;
  39. cin >> n;
  40. k1 = 1;
  41. for (i = 0; i < n; i++)
  42. {
  43. cin >> a[i];
  44. g[a[i]]++;
  45. ans ^= a[i];
  46. for (j = 1; j < 32; j++)
  47. {
  48. x = a[i]%(1LL<<j);
  49. if (x < 0)
  50. x += (1LL<<j);
  51. f[j][x]++;
  52. }
  53. }
  54. for (i = 0; i < n-1; i++)
  55. {
  56. //cout << ans << endl;
  57. k = 1;
  58. g[a[i]]--;
  59. if ((g[a[i]]&1)==k)
  60. {
  61. ans ^= -1;
  62. k ^= 1;
  63. }
  64.  
  65. for (j = 31; j >= 1; j--)
  66. {
  67. x = a[i]%(1LL<<j);
  68. if (x < 0)
  69. x += (1LL<<j);
  70. f[j][x]--;
  71. if ((f[j][x]&1) == k)
  72. {
  73. ans ^= j;
  74. k ^= 1;
  75. //cout << ans << endl;
  76. }
  77. }
  78. }
  79. cout << ans << endl;
  80. return 0;
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement