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
#include <iostream>

using namespace std;

string ones(unsigned long long number);

// int oneCount;


int main()
{
  std::ios_base::sync_with_stdio(false);

  int testCount;
  unsigned long long number;

  cin >> testCount;

  while(testCount--)
  {
    //oneCount = 0;
    string result;
    cin >> number;
    result = ones(number);
    cout << result << "\n"; //<<" ones = " << oneCount << "\n";
  }

  return 0;
}

string ones(unsigned long long number)
{

  if(number == 1)
  {
    // oneCount++;
    return "1";
  }
  if(number == 2)
  {
    // oneCount++;
    return "(1+1)";
  }

  if(number % 2 == 1)
  {
    // oneCount++;
    return "(1+" + ones(number - 1) + ")";
  }
  else
  {
    // oneCount += 2;
    return "(1+1)*" + ones(number / 2);
  }
}