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
47
48
49
50
51
52
53
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <utility>

using namespace std;

int x[50];

int main(){
	int a, b, c;
	int t = 1;
	scanf("%d", &c);
	for (int j = 1; j <= c; j++){
		scanf("%d", &a);
		if (a == 1){
			printf("1");
		}
		else{
			if (a == 2){
				printf("1+1");
			}
			else{
				b = 0;
				t = 1;
				while (a != 0){
					x[t] = a % 2;
					a = a / 2;
					b += x[t];
					t++;
					//cout << x[t - 1] << " ";
				}
				//cout << endl;
				b--;
				b = b - x[1];
				t--;
				for (int i = 1; i <= b; i++){
					printf("(");
				}
				printf("(1+1)");
				for (int i = t - 1; i >= 2; i--){
					if (x[i] == 1)
						printf("+1)");
					printf("*(1+1)");
				}
				if (x[1] == 1)
					printf("+1");
			}
		}
		printf("\n");
	}
	//system("pause");
}