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

bool is_least_bit_set(int k)
{
	return (k&1) != 0;
}

int main()
{
	int t;
	std::cin >> t;

	std::string result;

	for(int i_t = 0; i_t < t; ++i_t)
	{
		result.clear();

		int k;
		std::cin >> k;

		int parenthesis = 0;

		while(k > 0)
		{
			while(!is_least_bit_set(k))
			{
				result += "(1+1)*";
				k >>= 1;
			}

			if(k == 1)
				result += "1";
			else if(k > 1)
			{
				result += "(1+(1+1)*";
				++parenthesis;
			}
			k >>= 1;
		}

		while(parenthesis > 0)
		{
			result += ")";
			--parenthesis;
		}

		if(result.empty())
			std::cout << "NIE" << std::endl;
		else
			std::cout << result << std::endl;
	}
}