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
#include <bits/stdc++.h>
using namespace std;

int t, k, b[50], op;

int main () {
	scanf("%d", &t);
	while (t--) {
		op = 0;
		for (int i = 0; i < 50; i++) b[i] = 0;

		scanf("%d", &k);
		
		if (k == 1) { printf("1\n"); continue; }
		if (k == 2) { printf("1+1\n"); continue; }
		
		int i = 0; while (k > 0) { b[i] = (k & 1); k /= 2; ++i; }
		
		if (b[0] == 0) printf("(1+1)");
		else printf("1+(1+1)");

		int j = 1;
		while (j + 1 < i) {
			if (b[j] == 0) printf("*(1+1)");
			else { printf("*(1+(1+1)"); ++op; }
			++j;
		}
		while (op--) printf(")");
		printf("\n");
	}
	return 0;
}