Advertisement
Emiliatan

e319 - 1

Jul 22nd, 2019
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. /* e319 - 1         */
  2. /* AC (0.4s, 108KB) */
  3. #pragma warning( disable : 4996 )
  4. #include <cstdio>
  5. #include <cstdint>
  6. #include <cmath>
  7. #include <algorithm>
  8.  
  9. using namespace std;
  10.  
  11. using int16 = short;
  12. using uint16 = unsigned short;
  13. using uint = unsigned int;
  14. using int64 = long long;
  15. using uint64 = unsigned long long;
  16. using pii = pair<int, int>;
  17.  
  18. /* main code */
  19. int N, result = 0, x;
  20. int bit[33]{}, i;
  21.  
  22. int main()
  23. {
  24.     scanf("%d", &N);
  25.     while (N-- && scanf("%d", &x))
  26.     {
  27.         i = 0;
  28.         bit[32] += (x < 0);
  29.         x = abs(x);
  30.         while (x)
  31.             bit[i++] += x & 1, x >>= 1;
  32.     }
  33.  
  34.     for (i = 0; i < 32; ++i) (bit[i] % 3 ? result |= (1 << i) : 0);
  35.     if (bit[32] % 3) result = -result;
  36.        
  37.     printf("%d", result);
  38.  
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement