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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    int t, k;
    scanf("%i\n", &t);
    while (t--) {
        scanf("%i", &k);
        if (k == 1) {
            printf("1\n");
            continue;
        }
        int j = 0;
        int zamk = 0;
        int kk = k;
        int tdodac = -1;
        for (int i = 31; i >= 0; i--) {
            if (kk & 1) {
                if (tdodac != -1) {
                    for (int jj = tdodac - 1; jj >= 0; jj--) {
                        putchar('(');
                        putchar('1');
                        putchar('+');
                        putchar('1');
                        putchar(')');
                        putchar('*');
                    }
                    putchar('(');
                    putchar('1');
                    putchar('+');
                    zamk++;
                }
                tdodac = j;
                j = 1;
            } else {
                j++;
            }
            kk >>= 1;
        }
        if (tdodac != -1) {
            for (int jj = tdodac - 1; jj >= 0; jj--) {
                putchar('(');
                putchar('1');
                putchar('+');
                putchar('1');
                putchar(')');
                if (jj != 0)
                    putchar('*');
            }
        }
        while (zamk--) {
            putchar(')');
        }
        putchar('\n');
    }
    return 0;
}