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

void ones(int pow) {
    switch(pow) {
        case 0:
            std::cout << "1";
            break;
        case 1:
            std::cout << "1+1";
            break;
        default:
            std::cout << "(";
            ones(pow - 1);
            std::cout << ")*(";
            ones(pow - 1);
            std::cout << ")";
            break;
    }
}

int main() {
    std::ios_base::sync_with_stdio(0);

    int t;
    std::cin >> t;
    while(t --> 0) {
        int n;
        bool printed = false;

        std::cin >> n;
        for(int i=0; n!=0; n/=2, i++) {
            if(n % 2 == 1) {
                if(printed) {
                    std::cout<<"+";
                }
                ones(i);
                printed = true;
            }
        }
        std::cout << std::endl;
    }
}