#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
void solve()
{
int b=2,k;
int cnt=0;
scanf("%d",&k);
if(k==1){
printf("1\n");
return;
}
if(k%2) printf("1+(1*1)");
else printf("(1+1)");
while((ll)(b*2)<=k){
if(b&k){
printf("*(1+(1+1)");
cnt++;
}
else printf("*(1+1)");
b*=2;
}
while(cnt--) printf(")");
printf("\n");
}
int main()
{
int t;
scanf("%d",&t);
while(t--) solve();
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 | #include<bits/stdc++.h> using namespace std; typedef long long ll; void solve() { int b=2,k; int cnt=0; scanf("%d",&k); if(k==1){ printf("1\n"); return; } if(k%2) printf("1+(1*1)"); else printf("(1+1)"); while((ll)(b*2)<=k){ if(b&k){ printf("*(1+(1+1)"); cnt++; } else printf("*(1+1)"); b*=2; } while(cnt--) printf(")"); printf("\n"); } int main() { int t; scanf("%d",&t); while(t--) solve(); return 0; } |
English