1 #include <iostream> 2 #include <sstream> 3 #include <string> 4 #include <algorithm> 5 #include <vector> 6 #include <cmath> 7 using namespace std; 8 9 #define GI ({int _t; scanf("%d", &_t); _t;}) 10 #define FOR(i, a, b) for (int i=a; i<b; i++) 11 #define REP(i, a) FOR(i, 0, a) 12 template<class T> string toString(T n){ostringstream ost;ost<<n;ost.flush();return ost.str();} 13 int toInt(string s){int r=0;istringstream sin(s);sin>>r;return r;} 14 #define DBG(x) cout << #x << "::" << x << endl; 15 #define DBGV(_v) { REP(_i, _v.size()) { cout << _v[_i] << "\t";} cout << endl;} 16 #define sz size() 17 18 string binary_error_add (string s1, string s2) { 19 // Returns (s1 + s2). 20 // Works if s1 > 0 and s2 > 0 21 bool carry = false; 22 int cur=0; 23 string res = ""; 24 reverse(s1.begin(), s1.end()); 25 reverse(s2.begin(), s2.end()); 26 for (int i=0; i<s1.sz || i < s2.sz; i++) { 27 cur = 0; 28 if (i < s1.sz) { cur += s1[i]-'0'; } 29 if (i < s2.sz) { cur += s2[i]-'0';} 30 cur %= 2; 31 res += (char)(cur+'0'); 32 } 33 reverse(res.begin(), res.end()); 34 return res; 35 } 36 37 38 string converttobase(long long int num, int base) { 39 string res = ""; 40 while (num >= base) { 41 res += toString(num%base); 42 num /= base; 43 } 44 res += toString(num); 45 reverse(res.begin(), res.end()); 46 return res; 47 } 48 49 int binary2decimal(string s) { 50 int res = 0; 51 for(int i=s.size()-1, j=0; i>=0; i--, j++) { 52 res += (s[i]-'0')*(int)pow((double)2, (double)j); 53 } 54 return res; 55 } 56 57 int main() { 58 int a, b; 59 while (cin >> a && cin >> b) { 60 // cout << converttobase(a, 2) << endl; 61 // cout << converttobase(b, 2) << endl; 62 // cout << binary_error_add(converttobase(a, 2), converttobase(b, 2)) << endl; 63 cout << binary2decimal(binary_error_add(converttobase(a, 2), converttobase(b, 2))) << endl; 64 } 65 return 0; 66 }