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

using namespace std;
//brut:[
int t,n,x,q,i,licz;
bool c;
int main()
{
    ios_base::sync_with_stdio(0);
    cin>>t;
    while(t--)
    {
        cin>>n;
        licz=0;
        c=1;
        x=n;
        if(n==1) cout<<"1"<<endl;
        else if(n==2) cout<<"1+1"<<endl;
        else if(n==3) cout<<"1+1+1"<<endl;
        else
        {
            while(n>1)
            {
                if(n<x) cout<<"*(";
                if(n%2)
                {
                    cout<<"1+";

                    c=1;
                    if(n!=x) licz++;
                    --n;
                }

                if(c) cout<<"(1+1)";
                else cout<<"1+1)";
                n/=2;
                c=0;
            }
            while(licz--) cout<<')';
            cout<<endl;
        }
    }
    return 0;
}