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

std::string print_n(int n) 
{
    if (n==1) return "1";
    if (n==2) return "1+1";

    if (n%2) return print_n(n-1) + "+1";

    return "(" + print_n(n/2) + ")*(1+1)";
}

int main() 
{
    uint32_t n;
    scanf("%d\n", &n);
    for (size_t i = 0; i < n; ++i) {
        int v;
        scanf("%d", &v);
        printf("%s\n", print_n(v).c_str());
    }

    return 0;
}