/* Arkadiusz Wróbel
*
* Konkurs: Potyczki Algorytmiczne 2016, runda 2B
* Zadanie:
*/
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <queue>
#include <deque>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<PII> VPII;
typedef vector<VI> VVI;
#define REP(I, N) for(int I = 0; I < (N); ++I)
#define FOR(I, M, N) for(int I = (M); I <= (N); ++I)
#define FORD(I, M, N) for(int I = (M); I >= (N); --I)
//#define FOREACH(IT, CON) for(__typeof((CON).begin()) IT = (CON).begin(); IT != (CON).end(); ++IT)
#define ST first
#define ND second
#define MP make_pair
#define PB push_back
#define SIZE(CON) ((int)(CON).size())
#define ALL(CON) (CON).begin(), (CON).end()
const int INF = 1000000000;
const LL INFLL = 1000000000000000000LL;
//######################################################################
inline void make(const int n) {
if (n == 1) {
printf("1*1");
return;
}
if (n % 2) {
printf("1+");
}
printf("(1+1)*(");
make(n / 2);
printf(")");
}
int main() {
int T;
scanf("%d", &T);
REP(lpt, T) {
int n;
scanf("%d", &n);
make(n);
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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | /* Arkadiusz Wróbel * * Konkurs: Potyczki Algorytmiczne 2016, runda 2B * Zadanie: */ #include <cstdio> #include <iostream> #include <algorithm> #include <cmath> #include <cstring> #include <vector> #include <set> #include <map> #include <list> #include <queue> #include <deque> using namespace std; typedef long long LL; typedef unsigned long long ULL; typedef pair<int, int> PII; typedef vector<int> VI; typedef vector<LL> VLL; typedef vector<double> VD; typedef vector<string> VS; typedef vector<PII> VPII; typedef vector<VI> VVI; #define REP(I, N) for(int I = 0; I < (N); ++I) #define FOR(I, M, N) for(int I = (M); I <= (N); ++I) #define FORD(I, M, N) for(int I = (M); I >= (N); --I) //#define FOREACH(IT, CON) for(__typeof((CON).begin()) IT = (CON).begin(); IT != (CON).end(); ++IT) #define ST first #define ND second #define MP make_pair #define PB push_back #define SIZE(CON) ((int)(CON).size()) #define ALL(CON) (CON).begin(), (CON).end() const int INF = 1000000000; const LL INFLL = 1000000000000000000LL; //###################################################################### inline void make(const int n) { if (n == 1) { printf("1*1"); return; } if (n % 2) { printf("1+"); } printf("(1+1)*("); make(n / 2); printf(")"); } int main() { int T; scanf("%d", &T); REP(lpt, T) { int n; scanf("%d", &n); make(n); printf("\n"); } return 0; } |
English