96b8b260e1 2011-09-20 kinaba: #include <iostream> 96b8b260e1 2011-09-20 kinaba: #include <sstream> 96b8b260e1 2011-09-20 kinaba: #include <iomanip> 96b8b260e1 2011-09-20 kinaba: #include <vector> 96b8b260e1 2011-09-20 kinaba: #include <string> 96b8b260e1 2011-09-20 kinaba: #include <map> 96b8b260e1 2011-09-20 kinaba: #include <set> 96b8b260e1 2011-09-20 kinaba: #include <algorithm> 96b8b260e1 2011-09-20 kinaba: #include <numeric> 96b8b260e1 2011-09-20 kinaba: #include <iterator> 96b8b260e1 2011-09-20 kinaba: #include <functional> 96b8b260e1 2011-09-20 kinaba: #include <complex> 96b8b260e1 2011-09-20 kinaba: #include <queue> 96b8b260e1 2011-09-20 kinaba: #include <stack> 96b8b260e1 2011-09-20 kinaba: #include <cmath> 96b8b260e1 2011-09-20 kinaba: #include <cassert> 96b8b260e1 2011-09-20 kinaba: #include <cstring> 96b8b260e1 2011-09-20 kinaba: using namespace std; 96b8b260e1 2011-09-20 kinaba: typedef long long LL; 96b8b260e1 2011-09-20 kinaba: typedef complex<double> CMP; 96b8b260e1 2011-09-20 kinaba: 96b8b260e1 2011-09-20 kinaba: class BinaryCards { public: 96b8b260e1 2011-09-20 kinaba: long long largestNumber(long long A_, long long B_) 96b8b260e1 2011-09-20 kinaba: { 96b8b260e1 2011-09-20 kinaba: unsigned long long A = A_; 96b8b260e1 2011-09-20 kinaba: unsigned long long B = B_; 96b8b260e1 2011-09-20 kinaba: string sa; 96b8b260e1 2011-09-20 kinaba: for(int i=0; (1ULL<<i)<=A; ++i) 96b8b260e1 2011-09-20 kinaba: sa = char('0' + ((A>>i)&1)) + sa; 96b8b260e1 2011-09-20 kinaba: string sb; 96b8b260e1 2011-09-20 kinaba: for(int i=0; (1ULL<<i)<=B; ++i) 96b8b260e1 2011-09-20 kinaba: sb = char('0' + ((B>>i)&1)) + sb; 96b8b260e1 2011-09-20 kinaba: sa = string(sb.size()-sa.size(), '0') + sa; 96b8b260e1 2011-09-20 kinaba: 96b8b260e1 2011-09-20 kinaba: string sc; 96b8b260e1 2011-09-20 kinaba: for(int i=0; i<sb.size(); ++i) 96b8b260e1 2011-09-20 kinaba: if( sa[i] == sb[i] ) 96b8b260e1 2011-09-20 kinaba: sc += sa[i]; 96b8b260e1 2011-09-20 kinaba: else { 96b8b260e1 2011-09-20 kinaba: sc += string(sb.size()-i, '1'); 96b8b260e1 2011-09-20 kinaba: break; 96b8b260e1 2011-09-20 kinaba: } 96b8b260e1 2011-09-20 kinaba: 96b8b260e1 2011-09-20 kinaba: LL value = 0; 96b8b260e1 2011-09-20 kinaba: for(int i=0; i<sc.size(); ++i) 96b8b260e1 2011-09-20 kinaba: if( sc[sc.size()-i-1] == '1' ) 96b8b260e1 2011-09-20 kinaba: value |= (1LL << i); 96b8b260e1 2011-09-20 kinaba: return value; 96b8b260e1 2011-09-20 kinaba: } 96b8b260e1 2011-09-20 kinaba: }; 96b8b260e1 2011-09-20 kinaba: 96b8b260e1 2011-09-20 kinaba: 96b8b260e1 2011-09-20 kinaba: 96b8b260e1 2011-09-20 kinaba: // Powered by FileEdit 96b8b260e1 2011-09-20 kinaba: // Powered by TZTester 1.01 [25-Feb-2003] : <cafelier&naoya_t>-custom 96b8b260e1 2011-09-20 kinaba: // Powered by CodeProcessor