提交时间:2026-02-05 16:06:34
运行 ID: 84011
#include <iostream> #include <vector> #include <algorithm> using namespace std; class BigInt { vector<int> digits; public: BigInt(uint64_t num = 0) { while (num > 0) { digits.push_back(num % 10); num /= 10; } } BigInt operator-(const BigInt& other) const { BigInt res = *this; int borrow = 0; for (size_t i = 0; i < max(digits.size(), other.digits.size()); ++i) { int sub = (i < digits.size() ? digits[i] : 0) - (i < other.digits.size() ? other.digits[i] : 0) - borrow; if (sub < 0) { sub += 10; borrow = 1; } else { borrow = 0; } if (i < res.digits.size()) { res.digits[i] = sub; } else { res.digits.push_back(sub); } } while (res.digits.size() > 1 && res.digits.back() == 0) { res.digits.pop_back(); } return res; } friend BigInt operator<<(const BigInt& num, int shift) { BigInt res = num; res.digits.insert(res.digits.begin(), shift, 0); return res; } friend ostream& operator<<(ostream& os, const BigInt& num) { if (num.digits.empty()) return os << 0; for (auto it = num.digits.rbegin(); it != num.digits.rend(); ++it) { os << *it; } return os; } }; int main() { int n; while(cin >> n){ BigInt result = (BigInt(1) << (n + 1)) - BigInt(2); cout << result << endl; } return 0; }