#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef unsigned long long ul; typedef unsigned int ui; #define s second #define f first #define PB push_back #define REP(x,y) for(int x=0;x<(y);x++) #define ROF(x,y) for(int x=(y);x>=0;x--) #define FOR(x,y,z) for(int x=(y);x<(z);x++) #define INT(x) int x;scanf("%d",&x) #define LL(x) long long x;scanf("%lld",&x) #define STR(x) string x; cin>>x; #define CZ(x) char x; cin >> x; const ll hsz=996662137; const ll X=42; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef pair<int,pii> piii; pll expgcd(ll a,ll b){ if(b==0)return pll(1,0); pll x=expgcd(b,a%b); return pll(x.s,x.f-(a/b)*x.s); } int main(){ INT(T); while(T--){ INT(x); int cnt=0,l=0; while(x>2){ if(x&1){ printf("(1+"); x--; cnt++; //l++; } else{ printf("(1+1)*"); x/=2; //l+=2; } } if(x==2)printf("(1+1)"); else printf("1"); while(cnt>0){ printf(")"); cnt--; } puts(""); //printf("%d\n",l); } }
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 | #include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef unsigned long long ul; typedef unsigned int ui; #define s second #define f first #define PB push_back #define REP(x,y) for(int x=0;x<(y);x++) #define ROF(x,y) for(int x=(y);x>=0;x--) #define FOR(x,y,z) for(int x=(y);x<(z);x++) #define INT(x) int x;scanf("%d",&x) #define LL(x) long long x;scanf("%lld",&x) #define STR(x) string x; cin>>x; #define CZ(x) char x; cin >> x; const ll hsz=996662137; const ll X=42; typedef pair<int,int> pii; typedef pair<ll,ll> pll; typedef pair<int,pii> piii; pll expgcd(ll a,ll b){ if(b==0)return pll(1,0); pll x=expgcd(b,a%b); return pll(x.s,x.f-(a/b)*x.s); } int main(){ INT(T); while(T--){ INT(x); int cnt=0,l=0; while(x>2){ if(x&1){ printf("(1+"); x--; cnt++; //l++; } else{ printf("(1+1)*"); x/=2; //l+=2; } } if(x==2)printf("(1+1)"); else printf("1"); while(cnt>0){ printf(")"); cnt--; } puts(""); //printf("%d\n",l); } } |