Artifact Content
Not logged in

Artifact ab38c113cfe34364e9884067219d548d9a6809d3


#include <iostream> 
#include <sstream> 
#include <iomanip> 
#include <vector> 
#include <string> 
#include <map> 
#include <set> 
#include <algorithm> 
#include <numeric> 
#include <iterator> 
#include <functional> 
#include <complex> 
#include <queue> 
#include <stack> 
#include <cmath> 
#include <cassert> 
#include <cstring> 
using namespace std; 
typedef long long LL; 
typedef complex<double> CMP; 

class BinaryCards { public: 
  long long largestNumber(long long A_, long long B_) 
  { 
    unsigned long long A = A_; 
    unsigned long long B = B_; 
    string sa; 
    for(int i=0; (1ULL<<i)<=A; ++i) 
      sa = char('0' + ((A>>i)&1)) + sa; 
    string sb; 
    for(int i=0; (1ULL<<i)<=B; ++i) 
      sb = char('0' + ((B>>i)&1)) + sb; 
    sa = string(sb.size()-sa.size(), '0') + sa; 

    string sc; 
    for(int i=0; i<sb.size(); ++i) 
      if( sa[i] == sb[i] ) 
        sc += sa[i]; 
      else { 
        sc += string(sb.size()-i, '1'); 
        break; 
      } 

    LL value = 0; 
    for(int i=0; i<sc.size(); ++i) 
      if( sc[sc.size()-i-1] == '1' ) 
        value |= (1LL << i); 
    return value; 
  } 
}; 



// Powered by FileEdit
// Powered by TZTester 1.01 [25-Feb-2003] : <cafelier&naoya_t>-custom
// Powered by CodeProcessor