SHARE
TWEET

TAAND

a guest Aug 22nd, 2015 6 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <set>
  3. #include <string.h>
  4. #include <stdio.h>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     long long int N;
  11.     scanf("%lld", &N);
  12.  
  13.     unsigned long long int arr[32][2];
  14.  
  15.     long long int marked[32], maxn = -1;
  16.  
  17.     memset(arr, 0, sizeof(int)*32*2);
  18.     fill_n(marked, 32, 0);
  19.  
  20.     for(long long int i = 0; i<N; i++){
  21.  
  22.         unsigned long long int t;
  23.         scanf("%u", &t);
  24.  
  25.         int pow = 0;
  26.         unsigned long long int num = 1<<pow;
  27.  
  28.         while(num <= t){
  29.             if((num & t) > 0){
  30.                 marked[pow]++;
  31.                 if((marked[pow] > 1) && (maxn < pow))
  32.                     maxn = pow;
  33.                 if(arr[pow][0] < t){
  34.                     arr[pow][1] = arr[pow][0];
  35.                     arr[pow][0] = t;
  36.                 } else if(arr[pow][1] < t)
  37.                     arr[pow][1] = t;
  38.             }
  39.             pow++;
  40.             num = 1<<pow;
  41.         }
  42.     }
  43.     if(maxn == -1) printf("0\n");
  44.     else
  45.         printf("%u\n", (arr[maxn][0] & arr[maxn][1]));
  46.     return 0;
  47. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top