#include <iostream> #include <cmath> #include <vector> #include <set> #include <string> #include <list> #include <queue> #include <deque> #include <stack> #include <utility> #include <algorithm> #include <functional> using namespace std; typedef long long LL; typedef unsigned long long ULL; typedef long double LD; #define YES printf("TAK") #define NO printf("NIE") #define NL printf("\n") #define REP(__i,__n) for(int __i = 0; __i < (__n); ++__i) #define FOREACH(__it,__T) for (__typeof(__T.BEG) __it = __T.BEG; __it != __T.END; ++__it) #define FOR(__i,__beg,__end) for (int __i = __beg; __i <= (__end); ++__i) #define FORD(__i,__end,__beg) for (int __i = __end; __i >= __beg; --__i) #define DEB_STR(__T) FOREACH(______iterT,__T) printf("%d ",*______iterT); printf("\n"); #define IS_2POW(__n) (((__n^(__n-1))&__n) == __n) #define BEG begin() #define END end() #define PB push_back #define PF push_front #define PU push #define POB pop_back() #define POF pop_front() #define PO pop() #define MP make_pair #define F first #define S second const bool DEBUG = true; const int INF = 1000000010, MAX = 1000010; inline string simple (int w) { string res = "1"; REP(i,w-1) { res = res + "+1"; } return res; } inline string parity (int w) { if (w %2 == 0) return ")"; else return ")+1"; } string solve (int w) { if (w <= 5) return simple(w); return "(1+1)*(" + solve(w/2) + parity(w); } int t,n; int main () { ios_base :: sync_with_stdio(false); cin >> t; while (t--) { cin >> n; cout << solve(n) << "\n"; } return 0; }
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 | #include <iostream> #include <cmath> #include <vector> #include <set> #include <string> #include <list> #include <queue> #include <deque> #include <stack> #include <utility> #include <algorithm> #include <functional> using namespace std; typedef long long LL; typedef unsigned long long ULL; typedef long double LD; #define YES printf("TAK") #define NO printf("NIE") #define NL printf("\n") #define REP(__i,__n) for(int __i = 0; __i < (__n); ++__i) #define FOREACH(__it,__T) for (__typeof(__T.BEG) __it = __T.BEG; __it != __T.END; ++__it) #define FOR(__i,__beg,__end) for (int __i = __beg; __i <= (__end); ++__i) #define FORD(__i,__end,__beg) for (int __i = __end; __i >= __beg; --__i) #define DEB_STR(__T) FOREACH(______iterT,__T) printf("%d ",*______iterT); printf("\n"); #define IS_2POW(__n) (((__n^(__n-1))&__n) == __n) #define BEG begin() #define END end() #define PB push_back #define PF push_front #define PU push #define POB pop_back() #define POF pop_front() #define PO pop() #define MP make_pair #define F first #define S second const bool DEBUG = true; const int INF = 1000000010, MAX = 1000010; inline string simple (int w) { string res = "1"; REP(i,w-1) { res = res + "+1"; } return res; } inline string parity (int w) { if (w %2 == 0) return ")"; else return ")+1"; } string solve (int w) { if (w <= 5) return simple(w); return "(1+1)*(" + solve(w/2) + parity(w); } int t,n; int main () { ios_base :: sync_with_stdio(false); cin >> t; while (t--) { cin >> n; cout << solve(n) << "\n"; } return 0; } |