// Jedynki [B].cpp : Defines the entry point for the console application.
//
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <string>
#include <vector>
#include <iostream>
using namespace std;
string res(int n)
{
	if(n==1)return "1";
	string res;
	vector<int> tab;
	while (n)
	{
		tab.push_back(n % 2);
		n /= 2;
	}
	res="1";
	int onec=1;
	for (int i = tab.size() -2; i >= 0; --i)
	{
		res = res + "*(1+1)";
		onec+=2;
		if (tab[i] == 1)
		{
			res = "(" + res + "+1" + ")";
			onec+=1;
		}
	}
	return res;
}
int main()
{
	int t,n;
	scanf("%d", &t);
	while (t--)
	{
		scanf("%d", &n);
		cout << res(n) << "\n";
	}
	int a=1;
	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 38 39 40 41 42 43 44 45 46 | // Jedynki [B].cpp : Defines the entry point for the console application. // #define _CRT_SECURE_NO_WARNINGS #include <cstdio> #include <string> #include <vector> #include <iostream> using namespace std; string res(int n) { if(n==1)return "1"; string res; vector<int> tab; while (n) { tab.push_back(n % 2); n /= 2; } res="1"; int onec=1; for (int i = tab.size() -2; i >= 0; --i) { res = res + "*(1+1)"; onec+=2; if (tab[i] == 1) { res = "(" + res + "+1" + ")"; onec+=1; } } return res; } int main() { int t,n; scanf("%d", &t); while (t--) { scanf("%d", &n); cout << res(n) << "\n"; } int a=1; return 0; } | 
 
            
         English
                    English