#include <cstdio>
int main()
{
int i, k, t;
scanf ("%d", &t);
while (t--) {
scanf ("%d", &k);
if (k == 1) {
printf ("1\n");
continue;
}
for (i = -1; k > 1; k /= 2, i++) {
putchar ('(');
if (k % 2)
printf ("1+");
}
printf ("1+1)");
while (i--)
printf ("*(1+1))");
putchar ('\n');
}
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 | #include <cstdio> int main() { int i, k, t; scanf ("%d", &t); while (t--) { scanf ("%d", &k); if (k == 1) { printf ("1\n"); continue; } for (i = -1; k > 1; k /= 2, i++) { putchar ('('); if (k % 2) printf ("1+"); } printf ("1+1)"); while (i--) printf ("*(1+1))"); putchar ('\n'); } return 0; } |
English