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
45
#include<bits/stdc++.h>
using namespace std;
string a2="(1+1)";
string out;

int ile1(string & a){
int x=0;
for(int i=0;i<a.size();i++)
if(a[i]=='1')x++;
return x;
}

void wyp(int n){
if(n%2==1){out+="1+";n-=1;}
while(n%2==0)
{
n/=2;
out+=a2+"*";
};

if(n!=1){out+="(";wyp(n);out+=")";}
else{
out.erase(out.end()-1);
}

return;
}

int main(){
int Z;
cin>>Z;
while(Z--){
int n;
cin>>n;

if(n==1){cout<<1<<endl;continue;};
wyp(n);
cout<<out<<endl;
//cout<<ile1(out)<<endl;
out="";


}
return 0;
}