#include <bits/stdc++.h> using namespace std; #define fru(j,n) for(int j=0; j<(n); ++j) #define tr(it,v) for(auto it=(v).begin(); it!=(v).end(); ++it) //#define tr(it,v) for(typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it) #define x first #define y second #define pb push_back #define ALL(G) (G).begin(),(G).end() #if 1 #define DEB printf #else #define DEB(...) #endif typedef long long ll; typedef long long LL; typedef double D; typedef pair<int,int> pii; typedef vector<int> vi; const int inft = 1000000009; const int mod = 1000000007; const int MAXN = 1000006; int ile; void get(int n){ if(n%2){DEB("1");if(n!=1)DEB("+");n--;ile++;} if(n==0)return; if(n==2){DEB("1+1");ile+=2;return;} DEB("(1+1)*("); ile+=2; get(n/2); DEB(")"); } void solve(int nn) { int n; scanf("%d",&n); ile=0; get(n);DEB("\n"); } int main() { int te = 1; scanf("%d",&te); fru(ti,te) solve(ti+1); 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 | #include <bits/stdc++.h> using namespace std; #define fru(j,n) for(int j=0; j<(n); ++j) #define tr(it,v) for(auto it=(v).begin(); it!=(v).end(); ++it) //#define tr(it,v) for(typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it) #define x first #define y second #define pb push_back #define ALL(G) (G).begin(),(G).end() #if 1 #define DEB printf #else #define DEB(...) #endif typedef long long ll; typedef long long LL; typedef double D; typedef pair<int,int> pii; typedef vector<int> vi; const int inft = 1000000009; const int mod = 1000000007; const int MAXN = 1000006; int ile; void get(int n){ if(n%2){DEB("1");if(n!=1)DEB("+");n--;ile++;} if(n==0)return; if(n==2){DEB("1+1");ile+=2;return;} DEB("(1+1)*("); ile+=2; get(n/2); DEB(")"); } void solve(int nn) { int n; scanf("%d",&n); ile=0; get(n);DEB("\n"); } int main() { int te = 1; scanf("%d",&te); fru(ti,te) solve(ti+1); return 0; } |