#include <iostream> using namespace std; string divide2(string s) {//大数除二 string ans; int remainer = 0; for (int i = 0; i < s.size(); i++) { int temp = remainer * 10 + s[i] - '0'; ans += temp / 2 + '0'; remainer = temp % 2; } int pos = 0; while (ans[pos] == '0') pos++; ans = ans.substr(pos); if (ans.size() == 0) ans = "0"; return ans; } string multiply2(string s) {//大数乘二 string ans; int carry = 0; for (int i = s.size() - 1; i >= 0; i--) { int temp = (s[i] - '0') * 2 + carry; ans = to_string(temp % 10) + ans; carry = temp / 10; } if (carry != 0) ans = to_string(carry) + ans; return ans; } string add(string s,int a) {//大数加0或1 string ans; int carry = a; for (int i = s.size() - 1; i >= 0; i--) { int temp = s[i] - '0' + carry; ans = to_string(temp % 10) + ans; carry = temp / 10; } if (carry != 0) ans = to_string(carry) + ans; return ans; } string toBinary(string decStr) {//转二进制取余除二 string ans; if (decStr == "0") ans = "0"; while (decStr != "0") { ans = to_string((decStr[decStr.size() - 1] - '0') % 2) + ans; decStr = divide2(decStr); } return ans; } string reverseToDec(string binaryStr) {//二进制转10进制从高到低,逆序则从低到高 string ans = "0"; for (int i = binaryStr.size()-1; i >=0; i--) { ans = multiply2(ans); ans = add(ans, binaryStr[i] - '0'); } return ans; } int main() { string a; while (cin >> a ) { // 注意 while 处理多个 case cout << reverseToDec(toBinary(a)) << endl; } } // 64 位输出请用 printf("%lld")