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
57
58
#include <cstdio>
#include <cmath>
#include <vector>

using namespace std;


int main()
{

	long long int t, s, n;
	scanf("%lld", &t);
	for (int i = 0; i < t; i++)
	{
		scanf("%lld", &n);
		s = sqrt(n);
		long long int k = 2;
		long long int greater_than_100 = 0;
		vector<long long int> primes;
		while (n>1 && k <= s)
		{
			while (n%k == 0) 
			{	
				greater_than_100 += k;
				primes.push_back(k);
				n /= k;
			}
			++k;
		}

		if (n > 1) 
		{
			greater_than_100 += n;
				primes.push_back(n);
		}
		
		if (greater_than_100 <= 100 && primes.size() == 1)
		{
			for (int i = 1; i < primes[0]; i++) printf("1+");
			printf("1\n");
		}
		else if (greater_than_100 > 100) printf("NIE\n");
		else
		{
			for (int i = 0; i < primes.size(); i++)
			{
				printf("(");
				for (int j = 1; j < primes[i]; j++)
				{
					printf("1+");
				}
				if (i + 1 != primes.size()) printf("1)*");
				else printf("1)\n");
			}
		}
	}

}