提交时间:2024-08-20 23:41:53
运行 ID: 173676
#include <bits/stdc++.h> using namespace std; void solve(long long n) { if (n == 0) { return; } long long m2 = 1, index = 0; while (n >= m2 * 2) { m2 *= 2; index++; } n -= m2; if (index == 0) { cout << "2"; } else if (index == 1) { cout << "2"; } else { cout << "2("; solve(index); cout << ")"; } if (n > 0) { cout << "+"; solve(n); } } int main() { long long n; cin >> n; solve(n); return 0; }