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
60
61
62
63
64
65
66
67
68
#include <cstdio>

void jed(long k) {

/*
    we can represent all numbers < 1e9 with less than 100 'jedynek', so no need to bother with a 'NIE' answer
    2^30 > 10^9, at most 30 'jedynek' in binary representation, translates to at most 90 'jedynek'
 */
//    //  find the count of ones
//    long tmp = k;
//    long jed_count = 0;
//    while(tmp > 0) {
//        if (tmp % 2 == 1) jed_count+=3;
//        else jed_count += 2;
//        tmp >>= 1;
//    }
//
//    jed_count -= 2; //  adjust for no multiplication on 1
//
//    if (jed_count > 100){
//        printf("NIE\n");
//        return;
//    }

    //  find the representation
    long brackets = 0;

    while (k>4){

        if (k%2 == 1){
            printf("(1+");
            brackets+=1;
        }
        printf("(1+1)*");

        k >>= 1;
    }

    switch(k){
        case 1: printf("1"); break;
        case 2: printf("(1+1)"); break;
        case 3: printf("(1+1+1)"); break;
        case 4: printf("(1+1+1+1)"); break;
    }

    for (int i = 0; i<brackets; i++){
        printf(")");
    }

    printf("\n");

}

int main()
{

    long t;
    scanf(" %ld", &t);

    for (int i = 0; i < t; i++){
        long k;
        scanf(" %ld", &k);

        jed(k);
    }

    return 0;
}