#include <cctype> #include <cstdio> #include <iostream> using namespace std; void func1(int n) { if (n == 1) { cout << "2(0)"; return; } else { // 当n大于2时 int i, total = 0; cout << "2"; // 获取次方数 for (i = 2; i <= n; i *= 2 ) { total++; } if (total != 1) { // 将次方数递归 cout << "("; func1(total); cout << ")"; } // n - 2^total int number_y = n - i / 2; if (number_y != 0) { cout << "+"; func1(n = n - i / 2); } return; } } int main() { int number; while (scanf("%d", &number) != EOF) { func1(number); } return 0; } // 64 位输出请用 printf("%lld")