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 <cstdio>

using namespace std;

void printbinary(long locNumber)
{
   long openParenthesis = 0L;
   long test = locNumber;

   while(locNumber > 1L)
   {
      if(locNumber & 1L)
      {
         if(locNumber == test)
            printf("1+");
         else
         {
            printf("(1+");
            ++openParenthesis;
         }
      }

      if(locNumber > 3L)
         printf("(1+1)*");
      else
         printf("(1+1)");

      locNumber >>= 1;
   }

   while(openParenthesis--)
      printf(")");

   printf("\n");
}

void processNumber(long locNumber)
{
   if(locNumber == 1L)
      printf("1\n");
   else if (locNumber == 2L)
      printf("1+1\n");
   else
      printbinary(locNumber);
}

int main(int argc, char* argv[])
{
   long  tests = 0L;
   long mainNumber = 0L;

   scanf("%ld\n", &tests);

   while(tests--)
   {
      scanf("%ld\n", &mainNumber);
      processNumber(mainNumber);
   }
  
   return 0;
}