f

ljy123456 爱因斯坦 2022-06-26 18:33:34 2

#include

int a[15];

using namespace std;

void two(int n) {

int k;

for (k = 14; k >= 0; --k) {

    if (a[k] <= n)

        break;

}

if (k == 0)

    cout << "2(0)";

else if (k == 1)

    cout << "2";

else if (k == 2)

    cout << "2(2)";

else {

    cout << "2(";

    two(k);

    cout << ")";

}

if (a[k] < n) {

    cout << "+";

    two(n - a[k]);

}

}

int main() {

a[0] = 1;

for (int i = 1; i < 15; ++i) {

    a[i] = 2 * a[i - 1];

}

int n;

cin >> n;

two(n);

return 0;

}

{{ vote && vote.total.up }}