#include <iostream> #include<string> #include<vector> #include<algorithm> using namespace std; //采用引用可以避免拷贝 vector<int> div(vector<int>& a, int b, int& r) { int t = 0; vector<int>res; for (int i = a.size() - 1; i >= 0; i--) { int tmp = (t * 10+a[i]) / b; res.push_back(tmp); t = (t * 10 + a[i]) % b; } r = t; //翻转,处理前导0 reverse(res.begin(), res.end()); //由于要用试除法,所以这里判断条件要加等号 while (res.size() >= 1 && res.back() == 0)res.pop_back(); return res; } //高精度 int main() { string str; while (cin >> str) { vector<int>a; for (int i = str.size() - 1; i >= 0; i--) { a.push_back(str[i] - '0'); } int r = 0;//引用传递传回余数 vector<int>res; //然后写试除法 while (!div(a, 2, r).empty()) { a = div(a, 2, r); res.push_back(r); } res.push_back(r); for (int i = res.size() - 1; i >= 0; i--) { cout << res[i]; } puts(""); } } // 64 位输出请用 printf("%lld")