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
#include <iostream>
#include <cstdio>
#include <vector>
#define REP(i,n) for(int i=0; i<n; i++)
#define FOR(i,b,e) for(int i=b; i<=e; i++)
#define FORD(i,b,e) for(int i=b; i>=e; i--)
using namespace std;

int numBits(int x){
	int res = 0;
	while(x){
		x >>= 1;
		res++;
	}
	return res;
}

int main(){
	int t,x;
	cin >> t;
	while(t--){
		cin >> x;
		int nBits = numBits(x);
		if(x == 1){
			cout << 1 << endl;
			continue;
		}	
		string res = "1";
		FORD(i,nBits-2, 0){
			res = "(" + res + "*(1+1)";
			if( x & (1 << i)){
				res = res + "+1)";
			} else{
				res = res + ")";
			}
		}	
		cout << res << endl;
	}
}