1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <iostream>
#include <cassert>

#define FOR(i, a, b) for(int i=a; i <= b; ++i)

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    int t;
    cin >> t;
    FOR(k, 1, t) {
            int a, parent = 0;
            cin >> a;
            while (a != 1) {
                if (a % 2 == 1) {
                    cout << "1+";
                    --a;
                } else {
                    a /= 2;
                    cout << "(1+1)*" << (a % 2 == 1 && a != 1 ? "(" : "");
                    parent += (a % 2 == 1 && a != 1);
                }
            }
            cout << 1;
            FOR(i, 1, parent) {
                cout << ")";
            }
            cout << endl;
        }
    return 0;
}