/* C++11////////////////////////////////////////////////////////////////////////////////////////// #include <array> #include <unordered_map> //*//////////////////////////////////////////////////////////////////////////////////////////////// #include <bits/stdc++.h> ////////////////////////////////////////////////////////////////////////////////////////////////// #define P(i,a) for(int i=0;i<a;i++) #define P2(i,a,b) for (__typeof(b) i=a;i<b;i++) #define PR(i,a) for (long long i=a-1;i>=0;i--) #define PR2(i,a,b) for (long long i=b-1;i>=a;i--) #define FOREACH(i,t) for(__typeof(t.begin()) i=t.begin();i!=t.end();i++) #define VI vector<int> #define PB(a) push_back(a) #define PII pair<int,int> #define PLL pair<long long,long long> #define st first #define nd second #define ld long double #define ll long long #define MP make_pair #define MT make_tuple #define A(a) a.begin(),a.end() #define cmp_g(t) greater<t> #define inf numeric_limits<int>::max() #define llinf numeric_limits<long long>::max() #define troj tuple <int,int,int> #define czwor tuple <int,int,int,int> #define G(a,b) get<a>(b) #define C(a,siz) memset(a,0, siz*sizeof(a[0])) # define M_PI 3.14159265358979323846 ////////////////////////////////////////////////////////////////////////////////////////////////// #define DEBUG ////////////////////////////////////////////////////////////////////////////////////////////////// #ifdef DEBUG #define D(a) cerr<<#a<<"="<<a<<"\n" #define D2(a,b) cerr<<#a<<"="<<a<<" , "; D(b); #define D3(a,b,c) cerr<<#a<<"="<<a<<" , "; D2(b,c); #define DP(a) cerr<<#a<<"=["<<a.st<<","<<a.nd<<"]\n"; #define out(a,siz) cerr<<#a<<" [";cerr<<a[0];P2(i,1,siz)cerr<<","<<a[i];cerr<<"]\n"; #define out_it(a) cerr<<#a<<" ["; FOREACH(it69,a){cerr <<" "<<*it69<<" ,";}cerr<<"]\n"; #define out_itP(a) cerr<<#a<<" ["; FOREACH(it69,a){cerr <<" ["<<(*it69).st<<","<<(*it69).nd<<"] ,";}cerr<<"]\n"; #else #define D(a) (void(0)) #define D2(a,b) (void(0)) #define D3(a,b,c) (void(0)) #define DP(a) (void(0)) #define out(a,siz) (void(0)) #define out_it(a) (void(0)) #define out_itP(a) (void(0)) #endif ////////////////////////////////////////////////////////////////////////////////////////////////// //#define READFILE ////////////////////////////////////////////////////////////////////////////////////////////////// #ifdef READFILE #define pre(a); fstream in; in.open(a); #define cin in #else #define pre(a) (void(0)) #endif ////////////////////////////////////////////////////////////////////////////////////////////////// using namespace std; string jed="1"; string dwa="(1+1)"; string pom(int li) { if (li==1) {return "1";} if (li==2) {return "1+1";} if (li==3) {return "1+1+1";} if (li%2==1) { return "("+pom(li/2)+")*"+dwa+"+"+jed; } else { return "("+pom(li/2)+")*"+dwa; } } int main() { int t; cin >>t; while (t--) { int li; cin >>li; cout <<pom(li)<<"\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 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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | /* C++11////////////////////////////////////////////////////////////////////////////////////////// #include <array> #include <unordered_map> //*//////////////////////////////////////////////////////////////////////////////////////////////// #include <bits/stdc++.h> ////////////////////////////////////////////////////////////////////////////////////////////////// #define P(i,a) for(int i=0;i<a;i++) #define P2(i,a,b) for (__typeof(b) i=a;i<b;i++) #define PR(i,a) for (long long i=a-1;i>=0;i--) #define PR2(i,a,b) for (long long i=b-1;i>=a;i--) #define FOREACH(i,t) for(__typeof(t.begin()) i=t.begin();i!=t.end();i++) #define VI vector<int> #define PB(a) push_back(a) #define PII pair<int,int> #define PLL pair<long long,long long> #define st first #define nd second #define ld long double #define ll long long #define MP make_pair #define MT make_tuple #define A(a) a.begin(),a.end() #define cmp_g(t) greater<t> #define inf numeric_limits<int>::max() #define llinf numeric_limits<long long>::max() #define troj tuple <int,int,int> #define czwor tuple <int,int,int,int> #define G(a,b) get<a>(b) #define C(a,siz) memset(a,0, siz*sizeof(a[0])) # define M_PI 3.14159265358979323846 ////////////////////////////////////////////////////////////////////////////////////////////////// #define DEBUG ////////////////////////////////////////////////////////////////////////////////////////////////// #ifdef DEBUG #define D(a) cerr<<#a<<"="<<a<<"\n" #define D2(a,b) cerr<<#a<<"="<<a<<" , "; D(b); #define D3(a,b,c) cerr<<#a<<"="<<a<<" , "; D2(b,c); #define DP(a) cerr<<#a<<"=["<<a.st<<","<<a.nd<<"]\n"; #define out(a,siz) cerr<<#a<<" [";cerr<<a[0];P2(i,1,siz)cerr<<","<<a[i];cerr<<"]\n"; #define out_it(a) cerr<<#a<<" ["; FOREACH(it69,a){cerr <<" "<<*it69<<" ,";}cerr<<"]\n"; #define out_itP(a) cerr<<#a<<" ["; FOREACH(it69,a){cerr <<" ["<<(*it69).st<<","<<(*it69).nd<<"] ,";}cerr<<"]\n"; #else #define D(a) (void(0)) #define D2(a,b) (void(0)) #define D3(a,b,c) (void(0)) #define DP(a) (void(0)) #define out(a,siz) (void(0)) #define out_it(a) (void(0)) #define out_itP(a) (void(0)) #endif ////////////////////////////////////////////////////////////////////////////////////////////////// //#define READFILE ////////////////////////////////////////////////////////////////////////////////////////////////// #ifdef READFILE #define pre(a); fstream in; in.open(a); #define cin in #else #define pre(a) (void(0)) #endif ////////////////////////////////////////////////////////////////////////////////////////////////// using namespace std; string jed="1"; string dwa="(1+1)"; string pom(int li) { if (li==1) {return "1";} if (li==2) {return "1+1";} if (li==3) {return "1+1+1";} if (li%2==1) { return "("+pom(li/2)+")*"+dwa+"+"+jed; } else { return "("+pom(li/2)+")*"+dwa; } } int main() { int t; cin >>t; while (t--) { int li; cin >>li; cout <<pom(li)<<"\n"; } } |