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
#include <cstdio>
#include <vector>
using namespace std;

vector <int> lp = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97};

int main() {
    int t;
    scanf("%d", &t);
    for(int i = 0; i < t; i++) {
        int tmp;
        scanf("%d", &tmp);
        if(tmp == 1) {
            printf("1\n");
        } else {
            bool error = false;
            int i = 0;
            long long jedynki = 0;
            vector <int> liczby;
            while (tmp != 1) {
                if(i >= lp.size()) {
                    error = true;
                    break;
                }
                if(tmp % lp[i] == 0) {
                    if(jedynki + lp[i] > 100) {
                        error = true;
                        break;
                    } else {
                        jedynki+= lp[i];
                    }
                    liczby.push_back(lp[i]);
                    //printf("%d \n", lp[i]);
                    tmp /=lp[i];
                    i = 0;
                } else {
                    i++;
                }
            }
            if(error) {
                printf("NIE\n");
                continue;
            }
            
            for(int j = 0; j < liczby.size(); j++) {
                if(j!=0)printf("*");
                printf("(");
                for(int x = 0; x < liczby[j]; x++) {
                    if(x!=liczby[j]-1)
                        printf("1+");
                    else
                        printf("1");

                }
                printf(")");
            }
            printf("\n");
        }
        
    }
}