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
#include <cstdio>
#include <string>
#include <iostream>

static bool sync_with_stdio(false);

int binary[32];
int t;

void to_binary(int num) {
    for (int i = 0; i < 32; i++) {
        binary[i] = 0;
    }
    int pos = 0;
    while(num != 0) {
        binary[pos] = num % 2;
        num /= 2;
        pos++;
    }
}

void print_expression() {
    std::string expression = "";
    bool started = false;
    for (int i = 31; i >= 0; i--) {
        if (started) {
            if (binary[i] == 1) {
                expression = "(" + expression + "*(1+1)+1)";
            }
            else {
                expression = "(" + expression + "*(1+1))";
            }
        }
        else if (binary[i] == 1) {
            expression = "1";
            started = true;
        }
    }

    std::cout << expression << std::endl;
}

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

    for (int i = 0; i < t; i++) {
        scanf("%d", &num);
        to_binary(num);
        print_expression();
    }

    return 0;

}