#include <bits/stdc++.h> using namespace std; #define REP(i,a,b) for (int i = (a); i <= (b); ++i) #define FOR(i,n) REP(i,0,(int)n-1) #define mp make_pair #define ll long long #define pb push_back #define pii pair<int,int> #define VI vector<int> #define fi first #define se second void solve(int test) { int x; cin>>x; //cout<<x<<"\n"; int cnt = 0, res = 0; while(x > 0) { if(x == 1) { cout<<"1"; break; } if(x == 2) { cout<<"1+1"; break; } if(x == 3) { cout<<"1+1+1"; break; } if((x%2) == 1) cout<<"1+"; cout<<"(1+1)*("; //res+=3; cnt++; x/=2; } while(cnt--) cout<<")"; cout<<"\n"; //cout<<"1 count = "<<res<<"\n"; } int main() { ios_base::sync_with_stdio(0); int t; cin>>t; FOR(i,t) solve(i); 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 REP(i,a,b) for (int i = (a); i <= (b); ++i) #define FOR(i,n) REP(i,0,(int)n-1) #define mp make_pair #define ll long long #define pb push_back #define pii pair<int,int> #define VI vector<int> #define fi first #define se second void solve(int test) { int x; cin>>x; //cout<<x<<"\n"; int cnt = 0, res = 0; while(x > 0) { if(x == 1) { cout<<"1"; break; } if(x == 2) { cout<<"1+1"; break; } if(x == 3) { cout<<"1+1+1"; break; } if((x%2) == 1) cout<<"1+"; cout<<"(1+1)*("; //res+=3; cnt++; x/=2; } while(cnt--) cout<<")"; cout<<"\n"; //cout<<"1 count = "<<res<<"\n"; } int main() { ios_base::sync_with_stdio(0); int t; cin>>t; FOR(i,t) solve(i); return 0; } |