提交时间:2026-02-05 16:14:39

运行 ID: 84016

#include <iostream> #include <bitset> #include <algorithm> using namespace std; // 将 bitset 转换为字符串(高位在前) string bitset_to_string(const bitset<1000>& bs) { string s; for (int i = bs.size() - 1; i >= 0; --i) { s += bs[i] ? '1' : '0'; } // 移除前导零 s.erase(0, s.find_first_not_of('0')); return s.empty() ? "0" : s; } int main() { int n; while(cin >> n){ const int bits = 1000; // 足够大的位数 bitset<bits> result(1); // 初始化为 1 result <<= (n + 1); // 左移 n+1 位(相当于 2^(n+1)) result.set(0, 0); // 减去 2(即最低位置 0) cout << bitset_to_string(result) << endl;} return 0; }