#include<bits/stdc++.h>
using namespace std;
inline int read_int() {int x; cin >> x; return x;}
string ans(int x) {
string res;
int dod = 0;
for(int i=0;i<30;i++) {
if((1<<i) > x)
break;
if(i>0)
res += "(1+1)*";
if(x&(1<<i)) {
res += "(1+";
dod++;
}
}
for(int i=0;i<3;i++)
res.pop_back();
res.push_back('1');
for(int i=0;i<dod-1;i++)
res.push_back(')');
return res;
}
int main () {
ios_base::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while(t--)
cout << ans(read_int()) << "\n";
}
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 | #include<bits/stdc++.h> using namespace std; inline int read_int() {int x; cin >> x; return x;} string ans(int x) { string res; int dod = 0; for(int i=0;i<30;i++) { if((1<<i) > x) break; if(i>0) res += "(1+1)*"; if(x&(1<<i)) { res += "(1+"; dod++; } } for(int i=0;i<3;i++) res.pop_back(); res.push_back('1'); for(int i=0;i<dod-1;i++) res.push_back(')'); return res; } int main () { ios_base::sync_with_stdio(false); cin.tie(0); int t; cin >> t; while(t--) cout << ans(read_int()) << "\n"; } |
English