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 <stack>
#include <cstring>
using namespace std;
stack<int>S;
string wyn;
int main()
{
    ios_base::sync_with_stdio(0);
    int T;
    cin>>T;
    for(int t=0;t<T;t++)
    {
        wyn.clear();
        int a;
        cin>>a;
        if(a==1)cout<<"1"<<endl;
        else
        {
            while(a>0)
            {
                //if(a%2==1)cout<<"1"; else cout<<"0";
                if(a%2==1)S.push(1); else S.push(0);
                a=a/2;
            }
            S.pop();
            a=S.top();
            S.pop();
            if(a==0)wyn="1+1"; else wyn="(1+1)+1";
            while(!S.empty())
            {
                a=S.top();
                S.pop();
                if(a==0)wyn="("+wyn+")*(1+1)";
                else    wyn="("+wyn+")*(1+1)+1";
            }
            cout<<wyn<<endl;
        }
    }
}