Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. bool check(int x) {
  2.     int num = 0;
  3.    
  4.     while (x != 0) {
  5.         num += (x % 2);
  6.         x /= 2;
  7.     }
  8.    
  9.     if (num % 2 == 1) {
  10.         return true;
  11.     } else {
  12.         return false;
  13.     }
  14. }
  15.  
  16. long thePerfectTeam(vector<int> employeeRating) {
  17.     long res = 0;
  18.    
  19.     int n = (int) employeeRating.size();
  20.    
  21.     for (int i = 0; i < n; i++) {
  22.         for (int j = i + 1; j < n; j++) {
  23.             if (check(employeeRating[i] ^ employeeRating[j])) {
  24.                 res++;
  25.             }
  26.         }
  27.     }
  28.    
  29.     return res;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement