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
46
#include <cstdio>
#include <string>

int n, r, q;

std::string out = "";

void hor(int n, int ri)
{
	if(n == 1)
		return;

	int ro = n & 1;
	n >>= 1;
	
	hor(n, ro);

	if(n >= 2)
		out += "*";

	if(ro == 1)
		out = '(' + out + "(1+1)+1)";
	else
		out += "(1+1)";
	// if(n >= 2)
		// printf(" )");
	// printf("%d i: %d, o: %d\n", n, ri, ro);
}

int main(int argc, char const *argv[])
{
	scanf("%d", &q);
	while(q--)
	{
		out = "";
		scanf("%d", &n);
		if(n == 1)
			printf("1\n");
		else
		{
			hor(n, 0);
			printf("%s\n", out.c_str());
		}
	}
	return 0;
}