#include <cstdio> int t, n; int main() { scanf("%d", &t); while(t--) { scanf("%d", &n); int open = 0; while(n > 1) { if ((n % 2) == 1) { printf("(1+(1+1)*"); open++; } else { printf("(1+1)*"); } n /= 2; } printf("1"); while(open--) printf(")"); printf("\n"); } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #include <cstdio> int t, n; int main() { scanf("%d", &t); while(t--) { scanf("%d", &n); int open = 0; while(n > 1) { if ((n % 2) == 1) { printf("(1+(1+1)*"); open++; } else { printf("(1+1)*"); } n /= 2; } printf("1"); while(open--) printf(")"); printf("\n"); } } |