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
54
55
56
#include <iostream>
#include <string>

int main() {
	int t;
	scanf("%d", &t);
	int number_tab[100];
	std::string line_result;
	for (int i = 0; i < t ; i ++) {
		scanf("%d", &number_tab[i]);
	}
	int one_count = 0;
	for (int i = 0; i < t; i++) {
		line_result.clear();
		one_count = 0;
		if(number_tab[i] == 1) {
			line_result += "1";
		}
		int two_print = 0;
		int opener_number = 0;
		int temp = number_tab[i];
		while(temp != 1) {
			if(temp % 2 == 0) {
				temp = temp/2;
				if(two_print != 0) {
					line_result += "*(1+1)";
				} else {
					line_result += "(1+1)";
				}
				two_print++;
				one_count = one_count + 2;
			} else {
				if(temp == number_tab[i]) {
					line_result += "(1+";
				} else {
					line_result += "*(1+";
				}
				temp = temp - 1;
				two_print = 0;
				opener_number++;
				one_count++;
			}
		}
		if(number_tab[i] != 1) {
			while(opener_number != 0) {
				line_result += ")";
				opener_number--;
			}
		}
		if(one_count > 100) {
			std::cout << "NIE" << std::endl;
		} else {
			std::cout << line_result << std::endl;
		}
	}
}