#include <cstdio>
void test(int n) {
int b = 0;
while(n > 3) {
if(n & 1) printf("1+");
printf("(1+1)*(");
b++;
n >>= 1;
}
if(n == 3) printf("1+1+1");
if(n == 2) printf("1+1");
if(n == 1) printf("1");
while(b--) printf(")");
printf("\n");
}
int main() {
int t;
scanf("%i", &t);
while(t--) {
int n;
scanf("%i", &n);
test(n);
}
}
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 | #include <cstdio> void test(int n) { int b = 0; while(n > 3) { if(n & 1) printf("1+"); printf("(1+1)*("); b++; n >>= 1; } if(n == 3) printf("1+1+1"); if(n == 2) printf("1+1"); if(n == 1) printf("1"); while(b--) printf(")"); printf("\n"); } int main() { int t; scanf("%i", &t); while(t--) { int n; scanf("%i", &n); test(n); } } |
English