#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<cstring>
#include<string>
#include<iomanip>
using namespace std;
int testCases, k;
void wypisz(int x)
{
if (x == 1) { printf("1"); return; }
if (x % 2 == 0) { wypisz(x / 2); printf("*(1+1)"); }
else if (x % 2 == 1 && k != x) { printf("(("); wypisz(x / 2); printf("*(1+1)"); printf(")+1)"); }
else if (x % 2 == 1 && k == x) { wypisz(x / 2); printf("*(1+1)+1"); }
}
int main()
{
scanf("%d", &testCases);
while (testCases--)
{
scanf("%d", &k);
wypisz(k);
printf("\n");
}
getchar();
getchar();
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 | #define _CRT_SECURE_NO_WARNINGS #include<iostream> #include<cstdio> #include<algorithm> #include<vector> #include<stack> #include<queue> #include<set> #include<map> #include<cstring> #include<string> #include<iomanip> using namespace std; int testCases, k; void wypisz(int x) { if (x == 1) { printf("1"); return; } if (x % 2 == 0) { wypisz(x / 2); printf("*(1+1)"); } else if (x % 2 == 1 && k != x) { printf("(("); wypisz(x / 2); printf("*(1+1)"); printf(")+1)"); } else if (x % 2 == 1 && k == x) { wypisz(x / 2); printf("*(1+1)+1"); } } int main() { scanf("%d", &testCases); while (testCases--) { scanf("%d", &k); wypisz(k); printf("\n"); } getchar(); getchar(); return 0; } |
English