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
59
60
61
62
#include<iostream>
#include<cstdlib>
#include<vector>
#include<cmath>
using namespace std;
vector<int>tab[100];
 int n, pierw, pom,t,suma;
int main()
{
	ios_base::sync_with_stdio();
	cin>>t;
	for(int i=0;i<t;i++)
    {
		suma=0;
		cin>>n;
		if(n==1)
		{cout<<1;
			continue;
		}
        pierw = sqrt(n); 
        int k=2;
        while(n>1 && k<=pierw)
        {
                while(n%k==0)
                {
                        tab[i].push_back(k);
                        suma+=k;
                        n/=k;
                }
                ++k;
			if(suma>100)
				break;
        }
        if(n>1)
        {
			tab[i].push_back(n);
            suma+=n;
		}
		if(suma>100)
			cout<<"NIE\n";
		else
		{
			for(int j=0;j<tab[i].size();j++)
			{
				cout<<"(";
				for(int l=0;l<tab[i][j];l++)
				{
					cout<<"1";
					if(l<tab[i][j]-1)
					cout<<"+";
				}
				cout<<")";
				if(j<tab[i].size()-1)
					cout<<"*";
			}
		}
		cout<<"\n";
 
	}	
        return 0;
}