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
33
34
35
36
#include <cstdio>
#include <string>

using namespace std;

void calculateExpr(string *expr, int k) {
    size_t closingBracketsCount = 0;
    while (k > 1) {
        if (k % 2 == 0) {
            *expr += "(1+1)*";
            k /= 2;
        } else {
            *expr += "(1+";
            ++closingBracketsCount;
            --k;
        }
    }
    *expr += "1";
    (*expr).append(closingBracketsCount, ')');
}

int main() {
    int t;
    scanf("%d\n", &t);

    for (int ti = 0; ti < t; ++ti) {
        int k;
        scanf("%d", &k);

        string expr;
        calculateExpr(&expr, k);

        printf("%s\n", expr.c_str());
    }
    return 0;
}