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

int t, k;
string s;
string op;

string nawiasuj(string &s) {
  return "(" + s + ")"; 
}


int main() {
  scanf("%d",&t);
  while (t--) {
    scanf("%d",&k);
    s = "1";
    op = "";
    while (k > 1) {
      if(k%2) {
        op+="1";
        k -= 1;
      }
      else {
        op+="0";
        k /= 2;
      }
    }
    for (int i = op.size() - 1; i >= 0; --i) {
      if (op[i]=='0'){
        s += "*(1+1)";
      }
      else {
        s += "+1";
        s = nawiasuj(s);
      }
    }
    cout << s << endl;
  }
  return 0;
}