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
#include <bits/stdc++.h>
using namespace std;
string s, st;
int main()
{
    ios_base::sync_with_stdio(0);
    int z;
    scanf("%d", &z);
    while(z--)
    {
    unsigned long long n, mas, h, kek;
    scanf("%lld", &n);
    mas = 1; h = __builtin_popcount(n), kek = 0;
    while(h)
    {
        if(n&mas){s += "(1+"; h--;kek++;}
        if(h){s += "(1+1)*";}
        mas <<= 1;
    }
    st = s.substr(0, s.size()-3);
    kek--; st += '1';
    while(kek--)st += ")";
    cout << st << endl;
    s.clear();
    }
}