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

using namespace std;

int main()
{
    int t, i, a, x, j;
    ios_base::sync_with_stdio(0);
    cin >> t;
    for(i=0; i < t; i++)
    {
        string s;
        vector<int> b;
        cin >> a;
        x = a;
        while(x)
        {
            if(x%2)
                b.push_back(1);
            else
                b.push_back(0);
            x/=2;
        }
        s="1";
        for(j=b.size()-2; j>=0; j--)
        {
            if(b[j])
            {
                s = "(" + s + "*(1+1)+1)";
            }
            else
                s = s + "*(1+1)";
        }
        cout << s << "\n";
    }

    return 0;
}