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
// Hanczar

#include <cstdio>

#include <string>

void process(int v) {
  int parentis_hanging = 1;
  int groups = 0;
  bool addition_required =  v&1;
  std::string buf;
  int currvalue = v&1;
  int parenthasis = 0;

  for (int mask=2;currvalue != v;mask<<=1) {
    if (v&mask) {
      currvalue += mask;
    }
    if (addition_required) {
      if (!buf.empty()) {
        buf += '*';
      }
      buf+="(1+(1+1)";
      ++parenthasis;
    } else {
      if (!buf.empty()) {
        buf += '*';
      }
      buf+="(1+1)";
    }
    addition_required = v&mask;
  }
  for (int i=0;i<parenthasis;++i) {
    buf+=')';
  }
  if (buf.empty()) {
    printf("1\n");
  } else {
    printf("%s\n",buf.c_str());
  }
}

int main(int argc,char *argv[]) {
    int t;
    scanf("%d",&t);
    while(t--) {
      int v;
      scanf("%d",&v);
      process(v);
    }
    return 0;
}