#include <cstdio>
#include <ios>
using std::ios_base;
int main()
{
ios_base::sync_with_stdio(false);
int t;
scanf("%d", &t);
while (t--)
{
int k;
scanf("%d", &k);
int openedParenthesisCount = 0;
while (k > 1)
{
if (k % 2)
{
printf("(1+(1+1)*");
openedParenthesisCount++;
}
else
{
printf("(1+1)*");
}
k /= 2;
}
printf("1");
while (openedParenthesisCount--)
printf(")");
printf("\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 27 28 29 30 31 32 33 34 35 36 37 | #include <cstdio> #include <ios> using std::ios_base; int main() { ios_base::sync_with_stdio(false); int t; scanf("%d", &t); while (t--) { int k; scanf("%d", &k); int openedParenthesisCount = 0; while (k > 1) { if (k % 2) { printf("(1+(1+1)*"); openedParenthesisCount++; } else { printf("(1+1)*"); } k /= 2; } printf("1"); while (openedParenthesisCount--) printf(")"); printf("\n"); } return 0; } |
English